• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Crontab & Reboot

C

comptech520

Guest
Is there a way I can set up in the server crontab to reboot the server maybe every 2 weeks?

If so, how?

Thanks
 
What you're looking to do is execute the reboot command, In this example, we'll assume it's /usr/bin/reboot.

With CRON, there a 5 fields you can use to specify WHEN the command should be executed. The entry looks like this:

# # # # # <command>

An explanation of each field is below:

1 - A minute, expressed as a number from 0 through 59.
2 - An hour, expressed as a number from 0 through 23.
3 - A day of the month, expressed as a number from 1 through 31.
4 - A month of the year, expressed as a number from 1 through 12.
5 - A day of the week, expressed as a number from 0 through 6 (with 0 standing for Sunday).

So in your example, let's say we want to reboot at midnight on the 1st adn 15th of each month... The command would look like this:

0 0 1,15 * * /usr/bin/reboot -f

As you can see, we're setting the minute and hour fields to 0, which equates to midnight. The 'day of month' field is set to 1,15, which means the 1st and 15th of the month. The last two fields are set to *, which tell cron to match anything... CRON will only fire when ALL 5 fields are matched.

Make sense?
 
so basically, using fedora core 2 and plesk

in the server area of plesk I choose crontab

and use this as the command?

/usr/bin/reboot

thanks
 
Back
Top