Articles of shell

`pwd -P`防止bash脚本在supervisord中运行

我正在执行supervisord执行gunicorn。 我的问题是当我的脚本包含CURR_DIR =`pwd -P`并通过supervisord运行脚本时,它停止了这个过程。 我的脚本位于/var/www/conf ,我希望`pwd P`在运行脚本时返回/var/www/conf 。 我试过PWD,而且不会返回/var/www/conf 。 当我在supervisord之外运行脚本时,`pwd -P`工作。 但是,如果我硬编码CURR_DIR = /一些/目录,然后supervisord运行脚本没有问题。 这是我的脚本 #!/bin/bash NAME=myproj GUNICORN_EXEC=/home/user/.virtualenvs/tscoop/bin/gunicorn CURRENT_DIR=`pwd -P` # does not work: causes "STOPPED" error in supervisord CURRENT_DIR=/var/www/conf # works ok export GUNICORN_CONF=${CURRENT_DIR}/gunicorn.conf echo "Starting $NAME" exec $GUNICORN_EXEC -c $GUNICORN_CONF exit 0 这里是我从supervisorctl shell得到的错误信息: supervisor> status myscript STOPPED Aug 27 09:57 PM […]

在HPC集群中运行作业

我对HPC环境相当陌生。 在使用8个内核的节点上运行作业并在使用I内核的8个节点上运行相同的作业,在性能或使用的壁挂时间方面是否有区别。 PS:我正在开发一个项目,其中涉及在集群中运行一个脚本,大约需要2-3天才能完成输出。 因此,这样的疑问,以避免不相关的testing。

parsingaccess.log鱿鱼代理

我有日志文件access.log- *,我需要排除“TCP-DENY”(或只包含“TCP-MISS”)。 我如何parsing,如Linux上的grep命令,Windows上的access.log文件? 在Linux上它工作正常。 我需要做的Windows脚本(bash)。 谢谢

这个bash脚本有什么问题?

我发现一个initscript由于某种原因坚持以root用户身份启动指定的应用程序。 我无法围绕为什么这样做,任何提示? 该脚本在Redhat Enterprise Linux 5.9上运行。 #!/bin/bash # # Start/Stop apfe. # # chkconfig: – 62 38 # description: apfe # Start script for an apfe process. # Apfe does not normally run as root, so we change user # and call the real script in $USERDIR. STARTUSER=apfe USERDIR=/app/apfe/apps/apfeutils/bin PROGNAME=apfe su – $STARTUSER -c "$USERDIR/$PROGNAME […]

在shell脚本中使用统一选项?

我是新来的统一,并试图在一个简单的shell脚本中使用它的选项,但是当脚本执行时它们似乎被忽略,导致两个服务器之间没有更改同步。 我的shell脚本: #!/bin/bash # set paths / dirs _paths="/var/www/html/ \ " # binary file name _unison=/usr/bin/unison # Log in to remote server without a password source $HOME/.keychain/$HOSTNAME-sh # server names # sync node1.example.com with rest of the servers in cluster _rserver="node2.example.com" # sync it for r in ${_rserver} do for p in ${_paths} do ${_unison} […]

PowerShell不正确的结果

所以我有下面的脚本,基本上从robocopy任务中导入日志文件,然后通过电子邮件发送给我最后14行(基本上是最后的统计数据)。 不过,我似乎无法得到正确的格式。 这是脚本: $logfile_offsite = "C:\offsitebackup.log" $log_contents = Get-Content $logfile_offsite $date = Get-Date -Format g $footer = get-content $logfile_offsite | select-object -Last 14 #Send email $smtp_server = "smtp.server.com" $address_to = "[email protected]" $address_from = "[email protected]" Send-MailMessage -SmtpServer $smtp_server -To $address_to -From $address_from -Subject " Offsite Backup $date " -Body " $footer " 所以当电子邮件通过原来格式化,看起来整洁搞砸了。 有没有什么办法解决这一问题?

(bsnmpd),uid 0:退出信号6(核心转储)/语法错误:单词意外(期待“那么”)

我正在使用FreeBSD 9.2-RELEASE: # uname -a FreeBSD f9.alexus.org 9.2-RELEASE FreeBSD 9.2-RELEASE #0 r255898: Thu Sep 26 22:50:31 UTC 2013 [email protected]:/usr/obj/usr/src/sys/GENERIC amd64 # 每隔一段时间bsnmpd(1)为我产生以下信息: # bzip2 -cd /var/log/all.log.0.bz2 | grep bsnmpd Oct 12 21:01:44 f9 kernel: pid 62584 (bsnmpd), uid 0: exited on signal 6 (core dumped) # 我真的想弄清楚是什么造成的,但同时: # crontab -l | grep @hourly @hourly `which […]

在当前目录中查找超过5天的目录并将其归档

这是基本的问题。 我需要find当前工作目录中的文件夹(不是recursion的),如果他们超过5天归档它们。 压缩或tar.gz是好的。 我可以使用以下命令find文件夹 find./ -maxdepth 1 -type d -mtime +5 而且我知道我可以通过使用xargs查找的这个输出。 但我不知道如何存档与完整的文件夹名称。 那就是test1的目录应该被归档到test1.zip,而目录“test2”应该归档到“test2.zip”。 任何投入是受欢迎的。 问候

克隆到anacron迁移过程

我有一个脚本,我想在我的实验室的RHEL 5和6工作站上进行夜间运行,所以我将脚本部署到每个系统的/etc/cron.daily/目录,并使其可执行。 但是有些工作站在cron.daily运行的时候可能无法启动,所以我相信anacron可能更适合这个目的。 我将如何去转换这个简单的cron设置使用anacron而不是cron? 看来/ etc / anacrontab已经在/etc/cron.daily中运行脚本了: # /etc/anacrontab: configuration file for anacron # See anacron(8) and anacrontab(5) for details. SHELL=/bin/sh PATH=/sbin:/bin:/usr/sbin:/usr/bin MAILTO=root # the maximal random delay added to the base delay of the jobs RANDOM_DELAY=45 # the jobs will be started during the following hours only START_HOURS_RANGE=3-22 #period in days delay in […]

转移使用的公羊交换和释放更多的物理ram

我有一个256M物理RAM和512M交换空间的VPS, 我正在尝试使用一个需要超过256米,小于512米RAM的软件,所以它使用交换。 问题是在安装的某个时刻,安装过程检查可用的物理内存,它已满(使用了一些交换),所以它暂停安装,并继续安装,以便继续安装。 我看到我需要移动一些用过的物理内存,在进程运行的时候进行交换..有无论如何我可以做到这一点? 或任何其他解决scheme! 对不起,我正在使用openvz vps,并且vm.swappiness选项不能作为解决scheme进行修改。