• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1233
  • Last Modified:

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
0
travisbickle34
Asked:
travisbickle34
  • 2
  • 2
1 Solution
 
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

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now