Scheduling jobs using cron in Linux

cron is used to schedule the jobs in Linux. It allows you do below things.

  1. Add the job in crontab for specific user
  2. Remove the job in crontab
  3. View history of cron jobs

Adding new cron job

You can add cron job using below command.

crontab -e

Then you need to add the jobs using below syntax.

minute hour dayOfMonth month dayOfWeek <command>

For example – below command will schedule a cron job to run after every 20 minutes.

*/20 * * * * /home/myjob.sh

View cron jobs

Below command will list all cron jobs of current user.

$ crontab -l

Below command will list all cron jobs of given user.

$ crontab -u <user-name> -l

Removing cron jobs

Below command will remove all cron jobs of current user.

$ crontab -r

You may also like...