Script will not run correctly in crontab

Mack

Big Geek
Hi,
I am trying to run a script using crontab but for some reason its not working in crontab, but it works if I execute it manually.

The Script runs under user sysinfo and does the following:
a) runs a script called cfg2html as root (using sudo).
b) renames the output file.
c) copies the file to another server
d) then removes the file on the host server.

Script Contents:
sudo /export/home/sysinfo/cfg2html-1.6.4/cfg2html
mv /export/home/sysinfo/cfg2html-1.6.4/`uname -n`_cfg.html /export/home/sysinfo/cfg2html-1.6.4/`uname -n`_`date +%d-%m-%y`.html
scp /export/home/sysinfo/cfg2html-1.6.4/`uname -n`*.html sysinfo@admincon:/export/home/sysinfo/systemInfo/
rm -rf /export/home/sysinfo/cfg2html-1.6.4/`uname -n`*.*

* The keys have been exchanged between the two servers. In short, no password is required to log into the other system.
* The file, when run manually, gives the desired output
* The crontab entry is made in user sysinfo's crontab
* The crontab log file shows that the script was run at the intended time

The cfg2html script runs, since I have the ouput file genereated in the folder, but the files are not renamed nor scp to the other server and removed from the host server.

Oh yes the server is a SPARC running Solaris 10 (no Linux)

Any Suggestions

Thanks
 
hum,,.. might have found the issue

49 11 * * * /export/home/sysinfo/cfg2html-1.6.4/startscript.sh > /export/home/sysinfo/cfg2html-1.6.4/startscript.log 2>&1


mv: cannot access /export/home/sysinfo/cfg2html-1.6.4/legato02_cfg.html
/export/home/sysinfo/cfg2html-1.6.4/legato02*.html: No such file or directory
 
Found my error.....
Manual Execution was done while in /export/home/sysinfo/cfg2html folder, crontab executes it while in the users home folder /export/home/sysinfo

Hence the resulting html file location will be different in both cases
Manual Execution: /export/home/sysinfo/cfg2html/<systemName>_cfg.html
Crontab Execution: /export/home/sysinfo/<systemName>_cfg.html

Inshort, the <systemName>_cfg.html location changes depending on the folder from where the script was run.
 
Back
Top