我开始学习bash脚本,需要编写脚本在NGINX上安装fastcgi_cache 。 我需要使用fastcgi_cache设置replacePHP的默认位置。 要清楚,我需要取代这个: location ~ \.php$ { fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } 有了这个: location ~ .php$ { fastcgi_pass unix:/var/run/php5-fpm.sock ; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; access_log /var/log/nginx/$SITE_URL.cache.log cache; fastcgi_cache_key "$mobile$scheme$request_method$host$request_uri"; fastcgi_cache_bypass $skip_cache; fastcgi_no_cache $skip_cache; fastcgi_cache WORDPRESS; add_header X-Cache-Status $upstream_cache_status ; } 我相信这可以用sed来完成,但我找不到办法。 我设法通过一种解决方法来工作,如下所示: if [ -f "/etc/nginx/sites-enabled/$SITE_URL" ] then sed -i.bak […]
这是一个迫切的问题 所以这是我的问题: 我正在几台计算机的crontab上使用这个脚本,并且FTP会话没有结束,所以在几个FTP服务器阻塞万物和计算机崩溃之后 以下是QNAP TS-451 +的NAS服务器的configuration。 FTP处于活动状态: 最大FTP连接设置为512: 这里是FTP会话的代码: filename=foo.txt hostname=myserver.net remoteport=10021 path=/Web/PiTops_State/screen localpath=~/ username=admin password=***** ftp -inv -p <<FTPSEND open ${hostname} ${remoteport} user ${username} ${password} cd ${path} binary lcd ${localpath} put ${filename} bye FTPSEND 问题是,FTP会话似乎没有结束,所以我必须每天重新启动FTP服务器计算机是运行PitopOS的rasperi pi 3。 更新:添加 close bye 在最后没有工作
在远程服务器上,曾经有人可能使用sudo -u命令作为另一个用户执行某个命令,但是最近我无法完成这个任务。 当我这样做时,我收到以下错误: sudo -u lool ./autogen.sh /var/tmp/scltjLjKc: line 8: -u: command not found 所以我不得不使用sudo来root然后su执行命令之前的用户。 这可能是什么原因?
我configuration了automount实用程序来挂载我的USB闪存驱动器,当它插入。 它也将我当前的用户设置为装载点的所有者,但是当我尝试启动闪存驱动器时,系统会提示我input密码。 我的automount.conf ENABLED=1 MOUNTPOINTS="/media/usb0 /media/usb1 /media/usb2 /media/usb3 /media/usb4 /media/usb5 /media/usb6 /media/usb7" FILESYSTEMS="vfat ext2 ext3 ext4 hfsplus" MOUNTOPTIONS="noexec,nodev,noatime,nodiratime,uid=user,gid=user" FS_MOUNTOPTIONS="" VERBOSE=no 我怎样才能摆脱这个密码提示?
我目前正试图让一个脚本工作,需要定义一些LSBfunction。 这发生在这里: echo "step 1" # Read configuration variable file if it is present [ -r /etc/default/$NAME ] && . /etc/default/$NAME # Load the VERBOSE setting and other rcS variables [ -f /etc/default/rcS ] && . /etc/default/rcS echo "step 2" # Define LSB log_* functions. # Depend on lsb-base (>= 3.0-6) to ensure that this […]
我已经接受了一个艰巨的任务,就是将其中一台“原始”机器的软件包部署到其他机器上 – 总共大约有120台机器。 所有的机器都运行CentOS 6.8。 高级用户已经在原始机器上进行了function检查,并认为它值得所有的testing/模拟运行等。 你可能会认为这会像在原始机器上安装yum list> pristinemachine_pkgs.txt一样简单,然后在其他机器上安装yum install $(cat pristinemachine_pkgs.txt) 。 然而,在产生“包不可用”的yum结果中有足够的差异。 什么是工作是这样的: rpm -qa –qf="%{NAME}.%{ARCH}\n" | sort > pristinemachine_pkgs.txt 然后,在testing机器上: yum install $(cat pristinemachine_pkgs.txt) 但是,在这样做之后,我从原始机器和testing机器中find了一些问题。 显然,我的前任暂时启用了EPEL回购协议,安装了软件包,取消了回购协议,并安装了一次性的RPM。 谢天谢地,这个清单并不是那么庞大。 对于那些想知道我是怎么想到的,我在两台机器上运行了前一个RPM清单命令,并且运行了sdiff: http://pastebin.com/pFempAZN 然后从右列复制/粘贴项目到一个新的文件,现在正试图想出一些同时阅读行yum info extrarpms.txttypes的交易分析原始回购。 我有两个问题grep'ing: for i in $(cat extrarpms.txt); do yum info $i | grep Name && grep From; done 这里是extrarpms.txt的pastebin以供参考: http ://pastebin.com/VvPgU3vN […]
在Mac OS上,我的CI服务器的构build代理以root身份运行。 我已经与ruby版本上的defaul ruby -v报告2.0版,而后eval "$(rbenv init -)"正在执行,我得到所需的2.4。 如果我在每次login到shell时都要设置eval "$(rbenv init -)" ,我只要将它添加到我的〜/ .bash_profile中即可。 但是我假设从bash_profile执行命令的时候,我实际上是ssh作为用户。 我怎样才能确保Ruby的校正器命令得到执行与系统启动的根?
我需要更改现有的虚拟主机configuration文件。 我的目标是添加一个自定义的tmp-path到每个主机configuration,存储在/configs 。 也许可以在每个vHost-config中包含一个额外的configuration文件,允许使用某种placeholder在全局范围内进行设置? 就像是 include /configs/_additional.values 在每个vHostconfiguration和类似的东西 upload_tmp_dir /var/www/vhosts/$username/.tmp 在这个额外的configuration。 也许你在那里有一个想法?
我已经创build了一个logrotateconfiguration文件: touch /etc/logrotate.d/.test 与conficurations: /home/myUser/test*.log{ size 0 hourly rotate 0 nocreate nocompress missingok nocopytruncate ifempty } 我希望能够在每个条目(块日志文件)或某些日志文件之后清除文件以清除最后的“n”个条目。 实际上,我想继续这样做: truncate -s 0 /home/myUser/test*.log 实际上, nocopytruncate删除了日志文件。 如果我把copytruncate它创build每个日志“test * .log.1”的第二个日志,忽略rotate 0 。 如果我忽略下面的命令不做任何事情,忽略size 0 。 echo "hello" >> ~/test1.log cat ~/test1.log //output: hello 感觉像使用size不起作用。 为了这个工作,我需要执行: logrotate -f .test 难道我做错了什么? 是否有可能做到这一点通过使用logrotate并保持configuration文件以某种方式隐藏(原样)? 至于第二部分清除最后的'n'enries,我不知道我怎么能用logrotate做到这一点。
这段代码已经失败了好几天了,而且我的智慧已经结束了。 也许有人可以帮忙。 我已经编写了一个应该通过托pipeLinux系统循环的bash脚本。 它调用另一个bash脚本获得8个字段的logging: local cmd="/usr/local/sbin/zlsexpirations -s -l $nodeList" local expList # list of nodes and expiration days expList=`$cmd` # run the command … 所以variables'expList'有logging。 然后它应该遍历所有将它们传递给函数zSetOneSystem()的logging,以一次处理一个系统。 这是主循环(expList周围的双引号需要传递一个logging,而不只是一个令牌): local nextLine while read nextLine; do zVerbose "calling zSetOneSystem $nextLine" zSetOneSystem $nextLine done < <(echo "$expList") 这是我第一次尝试循环: echo "$expList" | while read nextLine; do zVerbose "calling zSetOneSystem $nextLine" […]