Linux timed Task execution

Source: Internet
Author: User


1) Write the shell script:

[email protected] cvv]# cat test1.sh

#!/bin/sh

/bin/date>>/home/cvv/test.log

echo "Hello world!" by cvv54 ">>/home/cvv/test.log

Give executable permission:

[Email protected] cvv]# chmod 777 test1.sh

2) Join the scheduled task queue with Crontab

Create a new cron file, write a program or command that requires a timed execution "absolute path required":

[email protected] cvv]# cat Rootcron

50,52,54 3 4/home/cvv/test1.sh

51,53,55 3 4/usr/bin/whoami>>/home/cvv/test.log

Submit a task to Cron:

[Email protected] cvv]# crontab Rootcron

To view tasks:

[Email protected] cvv]# crontab-l

#11月3日周四14点50-55 points Execute command

50,52,54 3 4/home/cvv/test1.sh

51,53,55 3 4/usr/bin/whoami>>/home/cvv/test.log

After the task is finished, delete:

[Email protected] cvv]# crontab-f

"Crontab usage: usage:crontab [-u user] File

crontab [-u user] [-e |-l |-r]

(default operation is replace, per 1003.2)

-E (Edit user ' s crontab)

-L (list user ' s crontab)

-R (Delete user ' s crontab)

-I (Prompt before deleting user ' s crontab)

-S (selinux context) "

The basic format of the crontab file is as follows

* * * * * command

Time-of-day months and weeks commands "

3) View Job completion status

[email protected] cvv]# cat Test.log

Hello World! by cvv54



Reference: http://www.jb51.net/LINUXjishu/19905.html

Http://blog.sina.com.cn/s/blog_7db69afe01017eof.html







Linux timed Task execution

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.