我有Ubuntu 10.04服务器与Lightspeed(networking服务器),PHP5,Mysql,TCPDF和sendmail我需要运行队列的cron作业,如果有任何工作已经运行,那么它必须创build队列,如果不是那么它将转到tcpdf文件夹sendmail。
因为我从serverfault得到了一个代码
`PIDFILE=/tmp/`basename $0`.pid if [ -f $PIDFILE ]; then if ps -p `cat $PIDFILE` > /dev/null 2>&1; then echo "$0 already running!" exit fi fi echo $$ > $PIDFILE trap 'rm -f "$PIDFILE" >/dev/null 2>&1' EXIT HUP KILL INT QUIT TERM`
但我没有得到如何运行显示可以帮助我一样对我的英语感到抱歉。
你可以在php中完成,例如my_cron.php内容:
<?php $pid = '/tmp/my_cron.pid'; if (file_exists($pid)) { echo "Already running."; exit; } else { exec ("touch $pid"); # create the pid file # do what you are supose to do here } unlink($pid); ?>
然后在你的cronjob有这样的东西:
23 0-23/2 * * * /usr/bin/php /path/to/my/php/file/my_cron.php