In a previous post, I explained the wonderful benefits of using Cron to schedule backups, log rotations, and any other task that can be automated. Cron makes automation very easy. There are times, however, when you will want to schedule a task but only want it to run once. A good example of this is a reboot.
First of all, I should clarify why you would even want to schedule a reboot. The best is example is that you may have just completed running updates on your dedicated server. If a kernel patch or new kernel version was included in the updates, you will need to reboot the server. Rather than just rebooting as soon as the updates finish, it might be wiser to wait until low usage times to reboot. For a server with clients in your geographical location, the best time to reboot might be 4 AM.
Rather than waiting until 4 AM to reboot, you can use the “at” command. It works rather simply. If, for example, you want the server to reboot at 4 AM on Saturday, enter this command as root:
at 4am saturday
After you press Enter, a prompt will open asking your for input. Type “reboot“.
Finally, press CTRL+D to save your settings. Your server will then reboot at the specified time.
Make sure you have some type server monitoring setup just in case your server fails to reboot. Also, you must remember that if you have a remote server, it may not have the same clock timezone as your local computer. While logged in via SSH, type “date” to see the current time. You can then compensate for time difference.
In addition to reboots, you can use the “at” command for any task you want to schedule only once or irregularly. For more information, type “man at” from the command line.
Cybercon.com is the leading expert in linux dedicated server Hosting with more than 15 years industry experience.