Difference between cron and shell in passing variables to a java process
Posted on 2004-08-27
I have a cron job that calls a shell script to monitor a process and if not running restart it BUT one of the variables is not passed if called from cron but is if the shell script is run directly.
OS is RHEL3.
cronjob is defined for a user (user1) as:-
0,15,30,45 * * * * /home/user1/monitor.sh
if pgrep -u $user $process >/dev/null; then
echo "`date` user1 down" >> /home/user1/logger
echo "`date` user1 down"
java -cp <jar stuff> "$UNITY_OPTS1" "$UNITY_OPTS2" <org stuff> start &
echo "`date` user1 restarted" >> /home/user1/logger
The problem variable is -DFile.encoding=UTF-8 defined in UNITY_OPTS2 it is NOT activated when the shell script is call from cron but YES if run
There is no difference if the -DFile.encoding=UTF-8 is put dirrectly on the java command or passed as variable as above..
<jar stuff> and <org stuff> refer to additional data that I've removed for clarity.
Everything works fine if -Dfile.encoding=UTF-8 is not used so I believe the script is okay just for that one variable there is a problem..