原因:定时任务脚本中的命令中包含了环境变量,crontab不能读取到环境变量。

vim /etc/cron.d/mymon
#mymon内容如下:
* * * * * root cd $GOPATH/src/mymon && ./mymon -c etc/mon.cfg

#应该修改为:
GOPATH=/home/go
* * * * * root cd $GOPATH/src/mymon && ./mymon -c etc/mon.cfg

 

/etc/cron.d添加定时任务脚本后不生效

 

参考资料:http://www.linuxquestions.org/questions/linux-newbie-8/etc-crontab-vs-etc-cron-d-vs-var-spool-cron-crontabs-853881/

相关文章:

  • 2021-09-03
  • 2022-12-23
  • 2021-07-21
  • 2022-02-09
  • 2021-10-28
  • 2022-12-23
  • 2021-04-28
  • 2021-06-27
猜你喜欢
  • 2022-12-23
  • 2021-06-02
  • 2021-11-25
  • 2022-12-23
  • 2021-12-14
  • 2021-06-20
  • 2022-02-26
相关资源
相似解决方案