I am trying to send a mail with at command, but the mail is getting delivered instantly, instead it should send the mail as per the time provided in at command. Below is the script:
#!/bin/bash
TODAY=`date +%Y%m%d`
echo 'Please enter the User-Name:'
read name
echo 'No. of days access is required - number only'
read NumberofDays
echo "Root access revoked for $name" | mailx -s "root access revoked for $name on $TODAY" xyz@example.com| at now + $NumberofDays
Notice the difference between these two statements:
at
at
The script you showed does the first, and you want to do the second:
cat << EOF | at "now + $NumberofDays days"
echo "Root access revoked for $name" | \
mailx -s "root access revoked for $name on $TODAY" xyz@example.com
EOF
I also added "days" after $NumberofDays
(thanks @User123 !) in the at
command's arguments, otherwise it's not correct syntax for at
.
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.