问题shell脚本如何遍历文件夹下所有文件?
方法:
dir="./sql_to_hdfs_init"
for file in `ls $dir/*`
do
echo $file # 输出 ./sql_to_hdfs_init/a.sh
if test -f $file;then # 相当于 if [ -f $file ];then
echo "执行:$file"
fi
done
问题shell脚本如何遍历文件夹下所有文件?
方法:
dir="./sql_to_hdfs_init"
for file in `ls $dir/*`
do
echo $file # 输出 ./sql_to_hdfs_init/a.sh
if test -f $file;then # 相当于 if [ -f $file ];then
echo "执行:$file"
fi
done
问题:如何判断subprocess.Popen运行的程序是否完成?
解决:通过ps aux可查看进程运行情况,如果命令已经完成,状态显示为:Z(僵尸进程)
方法:
# 查看进程12400的运行情况
ps aux | grep 12400
问题:linux生成随机密码,随机字符串
方法:
openssl rand -base64 12
openssl rand -hex 16
拓展:
使用pwgen模块,但需要先安装
问题:php-m命令查看到的模块与phpinfo()浏览器输出的模块不一样,phpinfo()中可以查看到mysqli模块,但php -m输出中没有
解决:这是因为php -m命令使用的cli下的配置,而phpinfo()使用的是fpm下的配置
方法:
cd /etc/php/7.4/cli
ln -s /etc/php/7.4/fpm/php.ini php.ini
配置cli目录下的模块
cd /etc/php/7.4/cli/conf.d
ln -s /etc/php/7.4/mods-available/mysqli.ini 20-mysqli.ini
问题:npm如何更换源?
方法:
1、查看当前源
npm config get registry
2、更换源
npm config set registry http://registry.npmmirror.com