Knowledgebase

Automating Routine Tasks with Cron Print

  • vpsservermanagement, cron, backup, domainrenewal, ssl, database, renewal, redirects
  • 0

Scheduling work on a server you control.

WHAT TO AUTOMATE

Backups Log rotation, if not handled by the system Database maintenance Certificate renewal, if not automatic Application scheduled tasks Cleanup of temporary files Monitoring checks

CREATING A JOB

Edit the crontab for the appropriate user. Jobs run as that user, so use the application's user for application tasks rather than root.

Use full paths to commands. Cron runs with a minimal environment and a command that works in your shell may not work in cron.

REDIRECTING OUTPUT

Send output to a log file rather than discarding it entirely, at least while testing. Discarding output means a failing job fails silently.

Configure an address to receive errors, or check the log.

TIMING

Spread jobs rather than scheduling everything at midnight. Several heavy jobs starting simultaneously cause the load spike you were trying to avoid.

Run backups and maintenance at genuinely quiet hours for your traffic.

TESTING

Run the command manually first and confirm it works. Then schedule it. Then check it ran.

THE COMMON FAILURE

A job that has been failing for months because nobody checked.


Was this answer helpful?
Back

Are you happy with your experience? Leave us a review on Trustpilot.


Trustpilot