Solution for How to auto schedule a job that asks for user input?
is Given Below:
#!/bin/bash
shutdown(){
echo "#### Query the azure vm tags ####"
echo " Please type YES or NO for **snooze/delay** to shutdown!"
read -p "YES/NO:" userinput
if [ $userinput == "YES" ]; then
read -p "delay_time:" snooze_time
echo " Update the azure vm tags based on snooze time"
sudo shutdown -k $snooze_time "System shutdown in $snooze_time"
else
sudo shutdown -k 05:00 "Sytem shutdown in 05:00 AM"
fi
}
shutdown
I have auto scheduled job through cron job but it is not asking for the user input to snooze the shutdown. It works fine manually. How can I get it to work with cron?