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" [email protected]| at now + $NumberofDays
Notice the difference between these two statements:
atatThe script you showed does the first, and you want to do the second:
I also added "days" after
$NumberofDays(thanks @User123!) in theatcommand's arguments, otherwise it's not correct syntax forat.