Scheduled task

We can record some schedule task at Linux. To do this we can use crontab command. We can add a scheduled task by command:

crontab -e

At the very first we should understand the basic structure of crontab command.

*           *           *            *          *          Command

1st * is the minutes of hour (0-59)

2nd * is the hour of day (0-23)

3rd star means day of month (1-31)

4th * means month of year (1-12)

5th * means day of week (0-6)

Now,

crontab -e

10     9   *     *      *      cp /etc/passwd /backup

This command will copy /etc/passwd file at /backup every day 9.10 am

crontab -e

*/10     *   *     *      *      cp /etc/passwd /backup

This command will copy /etc/passwd file at /backup after every 10 minutes.

10,30     9,17   *     *      6      cp /etc/passwd /backup

This command will copy /etc/passwd file at /backup every friday at hour between 9am and 5 pm and minute between 10min-30min

To check the scheduled list we can use

crontab -l

To remove schedule task we can use

crontab -r

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: