Task Scheduler for Linux Systems

Source: Internet
Author: User

Crontab Recurring Task Settings

# yum Install cronie-y# systemctl status crond.service# systemctl start crond.service# systemctl enable Crond.service
[[email protected] etc]# cat /etc/crontab shell=/bin/bashpath=/sbin:/bin:/usr/sbin:/ usr/binmailto=root# for details see man 4 crontabs# example of  job definition:# .---------------- minute  (0 - 59) # |  .--------- ---- hour  (0 - 23) # |  |  .---------- day of month   (1 - 31) # |  |  |  .------- month  (1 -  ( OR JAN,FEB,MAR,APR ...# |  |  |  | &NBSP):----  day of week  (0 - 6)   (sunday=0 or 7)  or sun,mon,tue,wed , thu,fri,sat# |  |  |  |  |# *  *  *   *  * user-name  command to be executed

To manage a user's scheduled tasks by using the crontab command

-E//Edit scheduled Task List-u//Specify which user the managed scheduled task belongs to, default to the current user, typically only the root user uses this option-l//list to display scheduled Tasks-r//Delete scheduled Task List

User Cron task Configuration Storage directory

[Email protected] etc]# ls/var/spool/cron/

Crontab-e

7 * * */USR/BIN/SYSTEMCTL Start SSHD50 * * */usr/bin/systemctl Stop sshd0 * */5 * */usr/bin/rm-rf/var/ftp/pub/ *30 7 * * 6/USR/BIN/SYTEMCTL Restart HTTPD30 * * 1,3,5/usr/bin/tar JCVF HTTPDCONF.TAR.BZ2/ETC/HTTPD

Note: When setting a task that is not performed every minute, the Minutes field should also fill in a specific time value instead of the default "*", otherwise the scheduled task will be executed every minute.

Confirm the contents of the root user's scheduled task list

[[email protected] etc]# CRONTAB-L50 7 * * */USR/BIN/SYSTEMCTL Start SSHD50 * * */usr/bin/systemctl stop sshd0 * */5 * */USR/BIN/RM-RF/VAR/FTP/PUB/*30 7 * * 6/USR/BIN/SYTEMCTL Restart HTTPD30 * * 1,3,5/usr/bin/tar JCVF httpdconf. Tar.bz2/etc/httpd

Confirm the contents of the Jerry user's scheduled Tasks list

[[email protected] ~]# crontab-l-u jerry55 * * 0/bin/cp/etc/passwd/home/jerry/pwd.txt[[email protected] ~]# ls-l /VAR/SPOOL/CRON/JERRY-RW-------. 1 Jerry Jerry 52 February 13:38/var/spool/cron/jerry

View and delete your own scheduled Tasks list after you log in with a Jerry user

[[email protected] ~]$ CRONTAB-L55 * * 0/bin/cp/etc/passwd/home/jerry/pwd.txt[[email protected] ~]$ Crontab-r[[ema Il protected] ~]$ crontab-lno crontab for Jerry

When you need to run multiple tasks in the same cycle, you typically write the related command action as a script file and then load the script in a scheduled task configuration and execute

Task Scheduler for Linux Systems

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.