How to create cron jobs

In any operating system, it is possible to create jobs that we want to reoccur. This process known as job scheduling. There are two tools to schedule jobs:

1. at
2. crontab

Crontab: Any user can create a cron job. As the root user, we can also have the ability to edit and remove any cron job. We can use crontab command to create, edit, and delete jobs.

Syntax: crontab [-U User] [option]

Options:

Option Description
-e Edits the users crontab.
-l Lists the users crontab
-r Deletes the users crontab
-i Prompts before deleting the users crontab

Crontab Job Definition:

How to create cron jobs

Examples:
*/02 * * * * date –> This will display for every two minutes
*/29 10 * * * cp file1 file2
25 20,12 03 * * /bin/echo “Welcome to K2schools”
45 10 02,11 10 * loging_name
59 23 31 12 * /bin/echo “Happy New Year”

To check the assigned cron jobs
crontab -l

TO check the cron job service status:
service crond status

Restart the cron service:
service crond restart
chkconfig crond on

To setu users crontab:
crontab -U user -e

To remove users crontab jobs:
crontab -U user -r

Related Posts

Responses are currently closed, but you can trackback from your own site.

Comments are closed.

Powered by k2schools