简体   繁体   中英

How can I use an at command in a shell script?

I am trying to use the Unix at command (for setting a job to run at a certain time) in a shell script. The time will be specified by user input using getopts and optarg which seem to be working fine, the problem is at . How do I write the at command into the script to run at a certain time based on input from the user?

Thanks, Ryan

I'd say

at now +10 minutes <<< "rm -rf /tmp/tobedeleted"

For multiline, consider a "HERE-doc"

at now +10 minutes <<ENDMARKER
rm -rf /tmp/tobedeleted
echo all done | mail -s 'completion notification' sysadmin@example.com
ENDMARKER

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