Link to home
Start Free TrialLog in
Avatar of travisbickle34
travisbickle34

asked on

Using crontab to run a .csh script as ROOT

Hi,

I'm relatively new to linux and I'm trying to set up a cronjob which runs a .csh script at a given time each day.  The script invokes a program called 'PTA'.  I can get the script to start ok as a cronjob but it does not run to completion.  At /var/spool/mail/root I receive a message telling me that the PTAHOME variable is not set.  

The thing is that I HAVE set this variable in both the .bashrc and .cshrc files and if I run the script from the command line it executes perfectly with no mention of the PTAHOME variable.  Has anyone got any suggestions as to what might be going wrong?

Cheers in advance,

tb34
Avatar of owensleftfoot
owensleftfoot

Simply set the variables in your script - cron runs with a different envirnment. So in the script which runs  PTA just do an  export PTAHOME= MYVAR (or whatever the csh equiv is).
Avatar of travisbickle34

ASKER

I have checked /etc/crontab and the cronjob is actually set to run in a the scripts in a bash shell.

However, when I include the PTAHOME definition in the cron file like this:


export PTAHOME=/paracel/paracel/pta/pta
48 11 * * * /export/home/penlims/Arragen.wrap
41 15 * * * /export/home/penlims/PipelineSummary.csh

I get this error message:

"Pipeline.cron":8: bad minute
errors in crontab file, can't install.

I think ownesleftfoot meant that you should set the variable in your *script* not in the crontab itself.

 
The fact that the script will run perfectly from the command line would suggest that the script is ok though, would it not?  Also, my wrapper script does contain a precautionary PTAHOME definition, although to be honest I don't think it is used.
ASKER CERTIFIED SOLUTION
Avatar of owensleftfoot
owensleftfoot

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial