简体   繁体   English

如何按计划通过cron重新启动。 Ubuntu 14.04

[英]How to reboot via cron on scheduled basis. Ubuntu 14.04

I have a very simple script that works from the command line. 我有一个非常简单的脚本,可以从命令行运行。

#!/bin/bash
reboot

When I put a call to execute the script into root users crontab -e using the following format it does not run. 当我使用以下格式向根用户crontab -e发出执行脚本的调用时,该脚本无法运行。 It does run the first two commands, just that last one is giving me grief. 它确实运行前两个命令,只是最后一个命令让我感到悲伤。 I have no MTA installed as I do not need it. 我没有安装MTA,因为我不需要它。

*/10 * * * * service jwtpay restart
0 3 * * * bash /root/backup/mongo.backup.s3.sh kickass /root/backup >/dev/null 2>&1
0 */3 * * * bash /root/reboot.sh >/dev/null 2>&1

What am I missing? 我想念什么?

Maybe the script is not executable... Since you use root's crontab why call the binary via a script and not the binary itself? 也许脚本不能执行...由于您使用root的crontab,为什么通过脚本而不是二进制本身调用二进制文件? Use the full path to the binary. 使用二进制文件的完整路径。 It may vary on your system. 在您的系统上可能有所不同。 Find out where it is with which reboot . 找出which reboot

0 */3 * * * /sbin/reboot

Don't forget to restart the cron daemon, after changeing the crontab. 更改crontab后,不要忘记重新启动cron守护程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM