I am new to scheduling tasks with cron and crontab. I am trying to schedule execution of a task as if I had logged on, opened a terminal, and executed it myself.
However, I scheduled a task to help me observe what $USER and $PATH a scheduled task is executing with, and this is what I found:
$ crontab -l
41 11 * * * echo "USER: $USER" > ~/Desktop/cron_env.log; echo "PATH: $PATH" >> ~/Desktop/cron_env.log
$ cat ~/Desktop/cron_env.log
USER:
PATH: /usr/bin:/bin
It appears as though $USER is not set, and $PATH is something very basic and/or default. On the contrary, this is what I see when I open a terminal (logged in) and echo this same information:
USER: aschirma
PATH: /usr/lib/jvm/java-6-sun/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/pkg/icetools/bin:/pkg/hwtools/bin:/pkg/netscape/bin:/pkg/gnu/bin
What do I need to do to make my crontab tasks run the way I want?