首页 > 解决方案 > 从命令行运行时脚本没有问题时 Crontab 给出错误

问题描述

我正在执行来自 crontab 的脚本,该脚本失败并给出以下错误(在 /var/log/messages 日志中)

2020-10-20T13:10:01.010834+01:00 AFGBE01-MN cron[1471]: (CRON) CAN'T FORK (do_command): Resource temporarily unavailable
2020-10-20T13:10:01.011251+01:00 AFGBE01-MN cron[1471]: message repeated 2 times: [ (CRON) CAN'T FORK (do_command): Resource temporarily unavailable]
2020-10-20T13:11:01.011487+01:00 AFGBE01-MN cron[1471]: (CRON) CAN'T FORK (do_command): Resource temporarily unavailable
2020-10-20T13:12:01.012671+01:00 AFGBE01-MN cron[1471]: message repeated 5 times: [ (CRON) CAN'T FORK (do_command): Resource temporarily unavailable]

当我从命令行运行时,脚本运行正常。我正在尝试在脚本中停止并启动一个进程。

#!/bin/sh
echo `date`|tee -a /tmp/new_test.txt
STATUS=`netstat -lntp | grep :9666 | awk -F ' ' '{print $6}'`
echo "Current Status" $STATUS |tee -a /tmp/new_test.txt
if [ -z "$STATUS" ]
#if [ $STATUS != "LISTEN" ]
then
/etc/init.d/<process> stop  | tee -a /tmp/new_test.txt
sleep 10
/etc/init.d/<process> start | tee -a /tmp/new_test.txt
fi

标签: shell

解决方案


推荐阅读