Linux Task Scheduler

Source: Internet
Author: User

Task Scheduler: Backup data at specific times, restart services, shell scripts, individual commands, and more.

Task Scheduler Profile: Cat/etc/crontab

[Email protected] ~]# Cat/etc/crontab

Shell=/bin/bash

Path=/sbin:/bin:/usr/sbin:/usr/bin

Mailto=root

# for details see Mans 4 Crontabs

# Example of Job definition:

#.----------------Minute (0-59)

# | .-------------Hour (0-23)

# |  | .----------Day of Month (1-31)

# |  |  | .-------month (1-12) OR jan,feb,mar,apr ...

# |  |  |  | .----Day of Week (0-6) (sunday=0 or 7) or Sun,mon,tue,wed,thu,fri,sat

# |  |  |  | |

# * * * * * * user-name command to be executed

Shell script, PATH environment variable, mailto send mail to WHO

Time:

Minutes, hours, days of the month, month, week, and finally, commands that need to be executed.

CRONTAB-E the task plan that needs to be performed.

Scripts executed 3 o'clock in the morning per day

0 3 * * */bin/bash/usr/local/sbin/123.sh >>/tmp/123.log 2>>/tmp/123.log

1 to 10th of the 3 points of the month can be divisible by 2, Week 2 and Week 5,

0 3 1-10 */2 2,5/bin/bash/usr/local/sbin/123.sh>>/tmp/123.log 2>>/tmp/123.log

To use an absolute path, for example iptables can be written as an absolute path or added to path

/usr/sbin/iptables

Start the service:

Systemctl Start Crond.service

To see if it starts:

PS aux |grep

Or:

Systemctl Status Crond

Crontab-u,-E,-L,-R

Format: Time-sharing Week user command

File/var/spool/cron/username

Sub-range 0-59, time range 0-23, day range 0-31, month range 0-12, week 1-6

Available formats 1-5 indicates a range of 1 to 5

Available formats 1 or 2 or 3

Available formats */2 represent numbers that are divisible by 2, such as hours, that is, every 2 hours to ensure that the service is in the boot state

Linux Task Scheduler

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.