[HELP] linux command restart machine scheduled

Soyeon

Member
Joined
Jul 22, 2014
Messages
311
Reaction score
1
i had tried google many website but most of the command i tried it wouldn't work on my Linux computer.

anyone know how to make my Linux machine do a soft-reboot every 8 hours?
or every 7am and 7pm.

i am really new to Linux just started to learn, please advise.
 

ykgoh

Master Member
Joined
Jan 1, 2000
Messages
2,782
Reaction score
0
You'll need cron.

  1. Edit your /etc/crontab file.
  2. Add in this line: 0 */8 * * * /sbin/reboot

To execute /sbin/reboot to restart the Linux machine, the user account must be root.

I'm not Linux/Unix expert.
 

ykgoh

Master Member
Joined
Jan 1, 2000
Messages
2,782
Reaction score
0
If you want a reboot at 7:00am and 7:00pm (12 hours in-between), then the line looks like:

Code:
0 7,19 * * * /sbin/reboot


You'll need to verify if this is correct and works as intended. Else you can page for resident expert davidktw. :s13:
 

ykgoh

Master Member
Joined
Jan 1, 2000
Messages
2,782
Reaction score
0
You'll need cron.

  1. Edit your /etc/crontab file.
  2. Add in this line: 0 */8 * * * /sbin/reboot

To execute /sbin/reboot to restart the Linux machine, the user account must be root.

I'm not Linux/Unix expert.

Just to add, to edit your root crontab file to run under root account, run:

Code:
sudo crontab -e

Otherwise, it'll edit your normal user crontab and won't be able to run /sbin/reboot successfully.
 

Rock-kun

Senior Member
Joined
Sep 10, 2007
Messages
991
Reaction score
1
if you are using Ubuntu (or Ubuntu-derived distributions), use sudo crontab -e to access the root cron.

For other distributions, you have to add the current user to the sudoers group, or you will get an error about sudo previleges. Alternatively, you can just use su like so:

Code:
su -
<enter root password>
crontab -e
 
Last edited:
Important Forum Advisory Note
This forum is moderated by volunteer moderators who will react only to members' feedback on posts. Moderators are not employees or representatives of HWZ Forums. Forum members and moderators are responsible for their own posts. Please refer to our Community Guidelines and Standards and Terms and Conditions for more information.
Top