shell - 从命令行运行时脚本没有问题时 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
解决方案
推荐阅读
- python - 如何计算列中的众数值,同时忽略此列中的值“-1”?
- node.js - router.post / 使用 Node JS、express、mongoose 将嵌套数组添加到 MongoDB 数据库
- bash - ECS/Fargate 容器定义命令参数
- excel - 在 Excel 2010 中寻找公式或 VBA 以输入今天的日期并将其冻结
- javascript - javascript中的乒乓球游戏碰撞
- php - 映射查询结果仅聚合在一个数字下
- mysql - 如何在mysql的内部连接中使用WHERE IN
- git - 防止 Git 推送覆盖目录
- spring-boot - 启动 Spring MVC 应用程序时出现 AbstractMethodError
- django - 限制对注册页面的访问。如何使其仅适用于未经身份验证的用户?