Skip to Content
Learning Linux Shell Scripting
book

Learning Linux Shell Scripting

by Ganesh Sanjiv Naik
December 2015
Beginner
306 pages
5h 2m
English
Packt Publishing
Content preview from Learning Linux Shell Scripting

Understanding "crontab"

If we need to run a specific task repetitively, then the solution is to use crontab.

The syntax of the command is as follows:

$  crontab    –e

This will open a new editor. The following diagram is the syntax to add tasks. The fields to use for repeating tasks at what time are explained here:

Understanding "crontab"

Finally, to save the jobs, use the following:

wq        # save and quite crontab job

The following are a few examples of the crontab command:

  • Use the following command to run a script every 5 minutes, every day:
    5 * * * *      $HOME/bin/daily.job >> $HOME/tmp/out  2>&1
    
  • Use the following command to run 5 minutes after midnight every day:
    5 0 * * * $HOME/bin/daily.job ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learning Linux Shell Scripting - Second Edition

Learning Linux Shell Scripting - Second Edition

Ganesh Sanjiv Naik

Publisher Resources

ISBN: 9781785286216