System Environment (CentOS 5)
Create a scheduled task in Linux:
(1) The first method is to configure the/etc/crontab file at the system running level. to execute all the scripts under/etc/daily at every day, the following format is used:
USER Command Script path or directory by hour, day, month, and week
18 15 * root run-parts/etc/cron. daily
Note: run-parts is used to execute all scripts in the directory.
The user column must be filled in. Generally, it is root.
If you only need to run a script, leave the command column empty (and do not need to *) and add the Path Directly after it, such as/etc/cron. daily/backup. sh (the script does not have to have a suffix)
After modification, the scheduled Task service (service crond restart) needs to be restarted to take effect.
(2) The second method is user-level. Execute the crontab-e command to directly add scheduled tasks. The format is similar to (1), but you do not need to specify a user, that is, the user column does not fill in anything (* No. is required), and the others are the same.