Linux Scheduled Tasks

Source: Internet
Author: User

Use at and cron to schedule tasks

At execution time

[[Email protected] ~]# Atq[[email protected]~]# atxx: - at> Cal >>/tmp/test-At.txtat>Date/tmp/test-At.txtat> <EOT>JobTenAt Sun Nov in xx: -:xx  -[[Email protected]~]# ATQTenSun Nov in xx: -:xx  -a root[[email protected]~]# at-cTen|Tail-6}${shell:-/bin/SH} <<'Marcindelimiter25c3ebf4'Cal>>/tmp/test-At.txtDate/tmp/test-At.txtmarcindelimiter25c3ebf4[[email protected]~]#[[email protected]~]# AT-Q g Teatime Tomorrowat> Cal >>/tmp/test-At.txtat> <EOT>Job OneAt Mon-Nov -  -:xx:xx  -[[Email protected]~]# At-q G -:xxTomorrowat> Cal >>/tmp/test-At.txtat> <EOT>Job AAt Mon-Nov -  -:xx:xx  -[[Email protected]~]# At-q b -:xxTomorrowat> Cal >>/tmp/test-At.txtat> <EOT>Job -At Mon-Nov -  -:xx:xx  -[[Email protected]~]# ATQTenSun Nov in xx: -:xx  -a root OneMon-Nov -  -:xx:xx  -g Root AMon-Nov -  -:xx:xx  -g Root -Mon-Nov -  -:xx:xx  -b root[[email protected]~]# ATRM Ayou in/var/spool/mail/There are new messages in root [[email protected]~]# ATQTenSun Nov in xx: -:xx  -a root
 11  Mon Nov 30  16 : 00 : 00  2015   g root  13  Mon Nov 30  17 : 00 : 00  2015   b root[[email protected] ~]#

[Email protected]/]# echo "cal >>/tmp/test-at.txt" | At 01:38
Job in Sun 29 01:38:00 2015
[Email protected]/]# ATQ
Mon-Nov-16:00:00 g root
Mon-Nov-17:00:00 B Root
Sun Nov 01:38:00 a root
[Email protected]/]#

Use Cron to schedule a recurring scheduled task

[email protected]/]# which tar
/bin/tar
[email protected]/]# which bash
/bin/bash

[Email protected]/]#Cat 1.SH
#!/bin/Bash
A=`Date+%y%m%d '
/bin/Tar-zpcf/$a.Tar. gz/var/log/*
[Email protected]/]# crontab-l
*/bin/date >>/time.txt (November 29 0:35)
1-5 */bin/date >>/time.txt (November 1 to 5th, 0:35)
*/1* * * * */bin/Date>>/ Time. txt (executes every minute)
- on* * 1,3,5/bin/bash/1.sh (1.sh scripts are executed once a week at 1, 3, 5 1:27)
[[Email protected]/]#

Linux Scheduled Tasks

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.