0

My main goal was to make a basic shell script that would close down my chromium tabs before shutting down. This was my script:

xdotool key ctrl+w & sleep 15; sudo shutdown -h now

After changing the permissions (with sudo chmod 755 ...) I added it to my user crontab with the following line:

0 21 * * * /home/pi/shutdown.sh   (shutdown.sh is what I named the script)

When I observed the shutdown, cron only seemed to execute the shutdown command and not the xdotool command. So I modified my script to the following in order to test it:

xdotool key h & sleep 15; sudo shutdown -h now

I punched the directory for my modified script into the terminal and it worked, so my ultimate question is why does the script work fine in the terminal, then only execute the shutdown command in cron? And how can I fix it?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.