我想用cron自动执行我的PHP邮件脚本。 我总是收到邮件两次。 手动启动时脚本运行正常。
我把这个放在crontab中进行testing:
54 13 * * * echo "This is a test" >> /opt/test.txt
,这两行打印到文件中。
这就是/ var / log / messages所说的:
Mar 3 13:54:01 server1 crontab[22076]: (root) BEGIN EDIT (root) Mar 3 13:54:01 server1 /usr/sbin/cron[2268]: (root) RELOAD (/var/spool/cron/tabs/root) Mar 3 13:54:01 server1 cron[19402]: (root) RELOAD (/var/spool/cron/tabs/root) Mar 3 13:54:01 server1 /USR/SBIN/CRON[22085]: (root) CMD (echo "This is a test" >> /opt/test.txt) Mar 3 13:54:01 server1 CRON[22086]: (root) CMD (echo "This is a test" >> /opt/test.txt)
另外, ps aux |grep cron
让我这个:
root 2268 0.0 0.0 3168 712 ? Ss Jan24 0:55 /usr/sbin/cron root 19402 0.0 0.0 3452 720 ? Ss Feb12 0:27 cron root 22538 0.0 0.0 2504 504 pts/0 S+ 14:06 0:00 grep cron
服务器的操作系统是openSUSE 11.4
干杯!
看起来有两个cron运行的实例:
你可能会杀死第二个实例。