Scheduling Tasks With Cron Print

  • 0

Running things automatically.

WHAT cron IS

A service that runs commands on a schedule.

WHAT A CRONTAB IS

The list of scheduled commands, per user.

HOW TO EDIT IT

crontab with the edit option.

WHAT THE FIVE FIELDS ARE

Minute Hour Day of month Month Day of week

WHAT AN ASTERISK MEANS

Every value.

WHAT A SLASH MEANS

A step, such as every fifteen minutes.

WHAT THE COMMONEST MISTAKE IS

Assuming the environment matches your shell.

WHY IT MATTERS

Cron runs with a minimal environment, so commands that work when typed fail silently.

WHAT TO DO ABOUT IT

Use absolute paths for every command and file.

WHAT THE SECOND COMMONEST MISTAKE IS

Discarding all output.

WHY THAT HURTS

Failures become invisible.

WHAT TO DO INSTEAD

Send output to a log file, and check it.

WHAT TO ALWAYS TEST

The exact command, run manually, before scheduling it.

WHAT TO GUARD AGAINST

Overlapping runs, when a job takes longer than its interval.

WHAT PREVENTS IT

A lock file, or flock.

WHAT TO CHECK WHEN A CRON JOB DID NOT RUN

The cron log, and whether the crontab belongs to the right user.


Was this answer helpful?
Back

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


Trustpilot