简体   繁体   中英

Using at command in shell script for scheduling a command

I am trying to use the feature of "at" command to schedule the execution of any specific command at some user defined time. Wondering if its possible using "at" command. I am hoping "at" could help me because I do not have privileges to schedule a cron task.

Things I have tried :

user>touch testfile |at 03:00  
job 30 at 2014-12-31 03:00  
user>ls -lrt testfile  
-rw-rw-r--  1 user group 0 Dec 31 02:59 testfile  <-----file created with command execution  
user>  

user> touch testfile1 | at -f 03:01
Garbled time
user>ls -lrt testfile*
-rw-rw-r--  1 user group 0 Dec 31 02:59 testfile
-rw-rw-r--  1 user group 0 Dec 31 02:59 testfile1

Use:

echo "touch testfile" | at 03:00

You're running touch testfile immediately, and piping its output to at . The input to at should be the command you want to run, not the output of the command.

If you want to run multiple commands, use a here-doc:

at 03:00 <<EOF
touch testfile
touch testfile1
EOF

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM