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