LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   testing shell scripts before entry into crontab. (https://www.linuxquestions.org/questions/linux-server-73/testing-shell-scripts-before-entry-into-crontab-762189/)

bartonski 10-15-2009 03:45 PM

testing shell scripts before entry into crontab.
 
I'm trying to run a cron job which calls a shell script that runs several queries against an Oracle database. I'm getting emails telling me that there are environment variables which are not set.

I would like to run the shell script in an environment which is as close as possible to how cron runs the script (except that I would actually like to see stdout and stderr, rather than having them echo to an email message).

I'm guessing that something like

Code:

sh --noprofile myscript.sh
should pretty well do the trick, but I may be missing something.

Also, is there a way to lauch a crontab entry manually, as if cron had just fired off? (yes, I know that I can set cron to fire off every minute, but that destroys my work flow).

chrism01 10-15-2009 08:28 PM

This page explains how to set env vars in your cron job, and which ones are (usually) set by default.
http://linux.die.net/man/5/crontab
The easiest soln is not to set them in the crontab, because you may have several different programs in there.
For a given job, set them at the top of the script.
Always use complete absolute paths to any cmds/files referenced, as the default cron env is minimal (see manpages).


All times are GMT -5. The time now is 11:43 AM.