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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cron job

Status
Not open for further replies.

Murugs

Technical User
Jun 24, 2002
549
US
Hello All
I tried setting up a cron job. I am running w2k server and have installed cygwin.
In a cygwin shell I issued crontab -e and vi editor popped up.
0 21 * * * pg_dump testdb>backup

This command makes a backup of a database testdb daily at 9 PM. But when I came in today I am not able to find my file.
If i do a ps -ef | grep cron
I see /usr/bin/crontab running
where I am going wrong?
 
It is likely because you user's environment variables, most notably, PATH, are not available to the cron job.

Use full path names everywhere. ______________________________________________________________________
TANSTAAFL!
 
I have redited the file and given like this
20 11 * * * /usr/bin/pg_dump testdb>/usr/bin/backup
still no luck..

any ideas
regards
MP
 
Why no try adding your commands to a shell script, then call the shell script from cron.
i.e:
------------------------------
! /bin/ksh
# clean_tmp.sh -- scour the old temp files from /tmp that
# belong to the user myuser.

thislist="/tmp/clean_tmp.list"

ls -l /tmp | grep "myuser" | awk '{print $9}' > $thislist

for i in `cat $thislist`
do
rm -r /tmp/$i
done
----------------------------------
Then, add it to the crontab:
45 23 * * * ~/bin/clean_tmp.sh

In this example, user "myuser"'s files get deleted at 11:45pm every night.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top