返回列表 發帖

centos要点样先可以指定时间重新启动系统?

有人话一般asterisk一个星期或一个月重新启动一次比较好,
所以如果我想使我的Elastix中的centos每个星期自动重新启动,唔知应该如何setting呢?
有人说要
corntal -e
然后输入  * 2 * * 1 reboot
保存退出

   *          2          *             *          1
分钟      小时     日        月      周

但是详细操作是如何?我不懂unix

你可以参考我以前在IP-01做的script或者cron job做也可以。

角色

TOP

回復 1# lttliang


    Your may try this

the command to reboot should be something like "shutdown -r now", where -r means to reboot (as opposed to -h which is halt).

Cron is the process for executing commands at a scheduled time. Crontab is the facility to schedule cron jobs. Cron jobs can be run by any user, but because you want to reboot, you'll need to do this as root.

Edit the cron table:
> crontab -e

Now you are in vi, editing the cron table. Add a line like:

0 1 * * * shutdown -r now >/dev/null

This command says, when the minute is 0 and the hour is 1, execute the command "shutdown -r now" and send any standard output to /dev/null (which cause the output to be thrown away).

If you wanted this to happen on only Monday and Friday, you'd change one of the asterisks (first one I believe) to 1,5 (sunday is 0). Do a man on crontab for more details.

TOP

回復  lttliang


    Your may try this

the command to reboot should be something like "shutdown -r ...
ckleea 發表於 2011-1-13 09:01



    shutdown  不是关机的意思吗?

TOP

shutdown 是關機的意思,但後面加了 -r  , 即加入之 reboot 重啟功能。

shutdown -r  = 關機再重啟

TOP

shutdown 是關機的意思,但後面加了 -r  , 即加入之 reboot 重啟功能。

shutdown -r  = 關機再重啟 ...
bubblestar 發表於 2011-1-13 12:24



    膜拜中。。。

TOP

回復 6# lttliang

You can replace with the word to "reboot" in the command line. "Reboot" works in centos but not every linux built.

TOP

返回列表