Play needs more: (Nor have I used the term "play" in any cron jobs)
Cron passes a minimal set of environment variables to your jobs.
A common "gotcha" here is the PATH environment variable being different. Maybe your cron script uses the command somecommand found in /opt/someApp/bin, which you've added to PATH in /etc/environment? cron ignores PATH from that file, so runnning somecommand from your script will fail when run with cron, but work when run in a terminal. It's worth noting that variables from /etc/environment will be passed on to cron jobs, just not the variables cron specifically sets itself, such as PATH.
To get around that, just set your own PATH variable at the top of the script. E.g.
Code:
#!/bin/bash
PATH=/opt/someApp/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
# rest of script follows
Some prefer to just use absolute paths to all the commands instead. I recommend against that.
Perhaps if you showed us the script your trying to use it would help us to help you.
Example of just one of my crontab -e......For just giving me the time every hour.
Code:
#!/usr/bin/env bash
my_date=$(date +'%I:%M:%S')
padsp espeak "$my_date"
My "crontab -e"reads as follows:
Code:
0 * * * * bin/say_hour
Enter the time (multiple times, days need to be separated with commas) and the script to execute for the alarm. The asterik can be used (*) to satisfy all variables. example for audacious:
Code:
07 21 * * 1,2,3,4,5 env DISPLAY=:0.0 audacious /home/user/My\ Music/Other/Alarms/301gq.mp3
Bookmarks