How do I create a cron job that runs a command or script at a certain time?
To create a cron job, log into SSH as the root user and run the following command to open the crontab editor:
Then, insert a new line containing the interval and the command that should be run. Hit the "i" key on your keyboard to enter "insert" mode.
0 2 * * * command_tool --with-arguments
The interval contains 5 parts. Minute, hour, day, month, and day of the week. The '*' entry means "every", so the above example means "at 0200 every day".
After adding this line, you will need to save the entry. If the editor is using "vi" or similar, to save and quit, you'll hit the ESC key, then type :wq and hit enter. There's no need to restart cron at this point, once you've saved the crontab, the cron is active. If your command has any output, it will typically be sent to your root contact. To avoid this, add "> /dev/null 2>&1" to the end of your command to silence the emails.