2

How can I schedule an automatic reboot of my server with CentOS via terminal or via plesk every 12 hours?

EEAA
  • 108,414
  • 18
  • 172
  • 242
paul_1991
  • 23
  • 3

1 Answers1

12

Add the following to root's crontab:

0 0,12 * * * /sbin/init 6

But honestly, why on God's green earth would you want to reboot every 12 hours?

EEAA
  • 108,414
  • 18
  • 172
  • 242
  • init 6 is the same of reboot? – paul_1991 May 31 '11 at 21:10
  • also reboot or shutdown -r would work as well in that cron job, but i echo @ErikA's point, why do you want to reboot every 12 hours – anthonysomerset May 31 '11 at 21:12
  • I have a problem on my server and i can't fix them in this week so i need to reboot it every 12 hour to save it from crash. How can I add this line? I run this command crontab -e and I get a list of all the scheduled process, how can I add the line that erikA suggest to me? Thanks – paul_1991 May 31 '11 at 21:15
  • @paul - there are many questions on SF about adding cron jobs. Just search for one and you'll find the information you're looking for. – EEAA May 31 '11 at 21:24
  • I run crontab -e and I simple add the line 0 0,12 * * * /sbin/init 6 then I save the file. Is everything ok? thanks – paul_1991 May 31 '11 at 21:50
  • @paul Yes, that should do it. Now just wait until midnight (in whatever timezone you server is set to) and see if it reboots. – EEAA May 31 '11 at 21:51
  • if I want to restart the server every 10 hours the command must be 0 0,10 * * * /sbin/init 6 right? thanks – paul_1991 Jun 01 '11 at 22:08
  • @paul No. See: http://mostlygeek.com/tech-reference/crontab-reference/ – EEAA Jun 01 '11 at 22:14