Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Crontab question

Status
Not open for further replies.

Kryolla

Technical User
Dec 6, 2001
35
How can I set this as a cron job ./whatever.txt

Thanks
 
Cron jobs are set up to run from the crontab files in /usr/spool/crontab. There are 5 default files in that directory (root, adm, lp, sys, uucp).

To edit the file root, you must be logged in as root. Set environment variable EDITOR to an editor like vi.

Example of c shell: setenv EDITOR vi

Run command "crontab -e".

The crontab for root will open in the editor. Make your entries and save the file.

Supposedly users can set up their own cron file but I have never tried it.
 
This is my crontab entry

00 13 * * * su – people –c /usr/users/fdsf/bin/whatever.txt.

When I run at the command line it works ./whatever.txt

Thanks
 
I would think that if you put the crontab under your user name in /usr/spool/crontab, it should run at the specified time. Check your syntax for the time and date entries to make sure they are correct (see man crontab). This man page also explains what is necessary for users to run their own crons.
 
If a script runs from the command line but not cron, then it is almost always an environment setting.
 
Thanks everyone I had to set the path in the script file as suggested. Is it possible to have it run the first sunday of every month.
 
Something like:

mm hh 1-7 * 0 <Your command>

So that the command is available for the first 7 days of each month but only executed when the day in question is a Sunday.
 
Sorry - that's rubbish, as it would execute the command on every Sunday in the month regardless, according to the man page. Too early in the morning!!

An alternative might be to include some logic in your script so that it decides for itself whether to run. Psuedo code:

If today = Sunday and dayofmonth < 8
then
do the necessary
else
don't bother
fi

Run this every day from cron and it should work.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top