Crontab Environments

I have a user trying to execute a command,in crontab, which requires certain envrionmental variables to be set. He is using tcsh on a Solaris 7 system. I have created a hack by doing the following in the crontab entry...

0 0-23 * * * rsh localhost -l user /path/command

This doesn't seem secure to me.

Any suggestions will be greatly appreciated.


[Edited by SmartJuniorUnix on 05-01-2001 at 01:52 PM]

Just set the environment variables directly in crontab (you can seperate commands with a semi-colon), or put everything in a script, and have crontab excute the script. If you want your .profile (or .cshrc or .login or whatever) to be executed, you will have to do it explicitly in your crontab entry.

I think what he is missing is the EDITOR variable. To use vi, execute

EDITOR=vi; export EDITOR

He may also need to be in the /etc/cron.d/cron.allow file on the local host

From what you are saying, it seems as though I can execute a command from crontab prior to running any entries



          • command1
          • command2

It this acurate?


Not quite. You would have to do something like:

          • source .profile ; /bin/your_command

Some versions of cron (such as Vixie Cron which is the version running on most Linux machines) will also allow you to have entries such as:


to set environment variables. Check the man page for your crontab to see if it is supported in your version.