Reputation: 231
I have script which runs manually fine but not getting the desired output when run through cronjob. Please let me know if anything wrong with the script.
#!/usr/bin/ksh
file1=$(find *-* -mtime 1)
file2=$(find *-* -mtime 2)
basefile1=$(basename $file1)
basefile2=$(basename $file2)
cd /gtxappl/Release/SCMAudit
./cmp.sh $basefile1 $basefile2 > dailyAuditChecks.txt
mailx -s "Daily Checks Report" ****@homeretailgroup.com < dailyAuditChecks.txt
Upvotes: 2
Views: 2562
Reputation: 1511
From Admin's Choice:
5. Crontab Environment cron invokes the command from the user’s HOME directory with the shell, (/usr/bin/sh). cron supplies a default environment for every shell, defining: HOME=user’s-home-directory LOGNAME=user’s-login-id PATH=/usr/bin:/usr/sbin:. SHELL=/usr/bin/sh Users who desire to have their .profile executed must explicitly do so in the crontab entry or in a script called by the entry.
I recommend using absolute paths wherever possible and don't forget about executing your .profile if you need environment variables.
Upvotes: 4