Linux scheduled tasks at cron

  
 

The scheduled task is to execute the scheduled task at the agreed time. In Linux, we use the crond service to complete the second job. The cron server can perform specific tasks according to the time specified in the configuration file. For example, we update the database every day at 4 am, which is a planned task.

Linux, there are three ways to implement scheduled tasks:

1 at Specify one time to perform one or more tasks, one time use

2 cron according to the timetable of the configuration file Automated tasks, periodic execution

3 System level mission planning and its extension anacron: Execute the scheduled task execution time as soon as possible after the defined frequency

Let's explain one by one: Br>

一:at:

#at 08:08

>echo "Hello"

>Ctrl+d(end)

The above lines indicate that Hello is output at 08:08, but it will not be processed, because the execution result will be sent to the execution user by email.

at -l or atq Query the currently scheduled task, as shown below

2 2011-05-21 01:01 a root

1 2011-05- 21 08:08 a root

The preceding number indicates the scheduled task number

at -d or atrm delete plan task

atrm 1

atrm 2

You can also delete the scheduled task by entering the /var/spoll/at directory, and the at scheduled tasks are saved in this directory.

Administrator users have access to at, normal users can use at depends on /etc/at.allow and /etc/at.deny files, both have permission to allow. Generally default to all users allowed.

Second: cron service, periodically execute a scheduled task

The cron service is provided by vixie-cron-4.1-76.e15 package, we can use rpm -qa (query all Installed package)

Copyright © Windows knowledge All Rights Reserved