Script will not run correctly in crontab

Discussion in 'Linux, BSD and Other OS's' started by Mack, Jan 10, 2010.

  1. Mack

    Mack Big Geek

    Likes Received:
    2
    Trophy Points:
    18
    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:
    * 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
     
  2. Mack

    Mack Big Geek

    Likes Received:
    2
    Trophy Points:
    18
    hum,,.. might have found the issue

     
  3. Mack

    Mack Big Geek

    Likes Received:
    2
    Trophy Points:
    18
    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.
     

Share This Page