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
travisbickle34Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

owensleftfootCommented:
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).
0
travisbickle34Author Commented:
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.

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

 
0
travisbickle34Author Commented:
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.
0
owensleftfootCommented:
Nah, I didnt mean put it in the crontab - put it in the script you are trying to run. If you are using cron to run pta directly, use a script instead ie call it runpta  make it executable chmod +x runpta and make sure it contains the variables you want and the command to run your program - ie

export PTAHOME=paracel/paracel/pta/pta
/path/to/my/program


then in cron you would have

48 11 *** /path-to-runpta/runpta
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.