I've got cronjob running this script every 20 minutes but I cannot understand how to make xterm open with it..
#!/bin/bash
xterm -hold -e "echo Time to relax"
play -q /home/username/music/relax.mp3 trim 0 01:20
sleep 120
exit 0
and in crontab -e
*/20 * * * * /home/username/Desktop/alarm.sh
The script runs fine but I just can't get xterm to open, Am I doing anything wrong here? When I run the script via terminal, ex: sh /home/username/Desktop/alarm.sh the terminal opens just fine and the song plays as well..
When the script is not started from within a X session, which is the case for a cron script, you need to pass the DISPLAY
environment variable:
DISPLAY=:0 xterm -hold -e "echo Time to relax"
If you are running a standard desktop system :0
should work as the value, otherwise you need to pass the correct value for your system.
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句