nothing seems to run from cron
Hello.
I am very new to linux. And please forgive me if I'm slow. Taking over from administrator leaving. Anyway. For some reason the backup jobs are no longer running. I have read some info. about cron and even wrote a script for testing. It does not run either. We're running an older version of Suse From my research I've found a couple of commands to see if the job is running: lptest:/var/log # ps -aux | grep "cron" root 25433 0.0 0.0 1428 4 ? S 2007 0:00 /usr/sbin/cron root 9163 0.0 0.0 1580 568 pts/0 S 10:00 0:00 grep cron lptest:/var/log # ls -lut /usr/sbin/cron ---x--x--x 1 root root 22904 Apr 3 09:42 /usr/sbin/cron lptest:/var/log # crontab -l # DO NOT EDIT THIS FILE - edit the master and reinstall. # (/tmp/crontab.9681 installed on Wed Apr 2 13:13:33 2008) # (Cron version -- $Id: crontab.c,v 2.13 1994/01/17 03:20:37 vixie Exp $) 0 3 * * * /usr/local/bin/db2backupwsc.sh 10 15 * * 1 /usr/local/bin/cleanupbk.sh 30 13* * * /usr/local/bin/commercebackup.sh 2 * * * * /usr/local/bin/funscript.sh > /usr/local/bin/funscript.log lptest:/var/log # In testing with my funscript.sh It only runs when I use the ./funscript.sh and not from cron. Any Ideas?? lptest:/var/log # ls -lut /usr/local/bin/funscript.log -rw-r--r-- 1 root root 25 Apr 2 11:51 /usr/local/bin/funscript.log lptest:/var/log # P.S. Please include the commands if possible in helping with my issue. |
may be you must put that command /usr/local/bin/funscript.sh > /usr/local/bin/funscript.log in another file like ffff.sh and add it to cron.
but it think there must be a better way of doing things |
Hi There,
Is this what you mean? # DO NOT EDIT THIS FILE - edit the master and reinstall. # (/tmp/crontab.11065 installed on Thu Apr 3 11:21:44 2008) # (Cron version -- $Id: crontab.c,v 2.13 1994/01/17 03:20:37 vixie Exp $) 0 3 * * * /usr/local/bin/db2backupwsc.sh 10 15 * * 1 /usr/local/bin/cleanupbk.sh 30 13* * * /usr/local/bin/commercebackup.sh 2 * * * * /usr/local/bin/ffff.sh lptest:/usr/local/bin # ffff.sh #!/bin/sh # # # Fun script to say Hello. Just to see how crontab works. # SHELL=/bin/bash PATH=/sbin:/bin:/usr/local/sbin:/usr/local/bin ./funscript.sh >> /usr/local/bin/funscript.log echo "hello Chris, you did it!" It still has not updated the file every 2 minutes. |
I'm really trying here guys. Again my apology for my lack of knowledge.
I think this says crontab has not been accessed since Jan22. lptest:/usr/local/bin # ls -lut /etc/crontab -rw-r--r-- 1 root root 511 Jan 22 10:00 /etc/crontab lptest:/usr/local/bin # cron seems to be running so why has it not been accessed??? Should I reboot the server or is there a way to wake it up. or Can I kill it, but I have no idea how to start the cron deamon again. lptest:/usr/local/bin # ps -el | grep "cron" 002 S 0 25433 1 0 75 0 - 357 schedu ? 00:00:00 cron lptest:/usr/local/bin # lptest:/usr/local/bin # ps -u root | grep 25433 25433 ? 00:00:00 cron lptest:/usr/local/bin # |
Try this :
In cron put the line 2 * * * * /usr/local/bin/funscript.sh contents of /usr/local/bin/funscript.sh /usr/bin/touch /usr/local/bin/funscript.dat Make sure script has execute perms If you want to specify the shell to use (usually a good idea, not that on my machine (openSUSE 10.2), the shell paths are: prompt:>which sh prompt:>/usr/bin/sh prompt:>which bash prompt:>/bin/bash note that that's different to your /bin/sh invocation. Use the 'which' cmd to check If cron is running, but having a problem with your script(s), it'll normally email the crontab owner eg root with details, so login as eg root and use the cmd mailx note also that cron has a minimal default env, so it's advisable to always specify complete paths to cmds & files. Here's a good cron tutorial: http://www.adminschoice.com/docs/cro...Crontab%20file |
Thanks Chris.
I was away on Friday, so I will take a look at this today and let you know. |
Hi Chris
I have done everything as root user. Please check the permissions, I think they are OK. Testing the command: lptest:/usr/local/bin # /usr/bin/touch /usr/local/bin/funscript.dat lptest:/usr/local/bin # ls -lut /usr/local/bin/funscript.dat -rw-r--r-- 1 root root 0 2008-04-08 14:23 /usr/local/bin/funscript.dat Running the command: lptest:/usr/local/bin # ./funscript.sh lptest:/usr/local/bin # ls -lut /usr/local/bin/funscript.dat -rw-r--r-- 1 root root 0 2008-04-08 14:26 /usr/local/bin/funscript.dat Testing the file was touched: lptest:/usr/local/bin # date Tue Apr 8 14:26:31 EDT 2008 lptest:/usr/local/bin # ls -lut /usr/local/bin/funscript.sh -rwxr-xr-x 1 root root 215 2008-04-08 14:26 /usr/local/bin/funscript.sh Looking from sh and bash location: lptest:/usr/local/bin # which sh /bin/sh lptest:/usr/local/bin # which bash /bin/bash lptest:/usr/local/bin # Checking my Path: lptest:/usr/local/bin # echo $PATH /usr/sbin:/bin:/usr/bin:/sbin:/usr/X11R6/bin lptest:/usr/local/bin # Cron: lptest:/usr/local/bin # crontab -l # DO NOT EDIT THIS FILE - edit the master and reinstall. # (/tmp/crontab.16260 installed on Mon Apr 7 10:10:43 2008) # (Cron version -- $Id: crontab.c,v 2.13 1994/01/17 03:20:37 vixie Exp $) 0 3 * * * /usr/local/bin/db2backupwsc.sh 10 15 * * 1 /usr/local/bin/cleanupbk.sh 30 13* * * /usr/local/bin/commercebackup.sh 2 * * * * /usr/local/bin/funscript.sh lptest:/usr/local/bin # Checking if cron is running the job every 2 min: lptest:/usr/local/bin # ls -lut /usr/local/bin/funscript.dat -rwxr-xr-x 1 root root 0 2008-04-08 14:26 /usr/local/bin/funscript.dat lptest:/usr/local/bin # Hi Chris, One thing I did notice, is if I'm not in the /usr/local/bin directory I cannot run the ./funscript.sh So maybe the problem is my Path. Do you think this could be the issue? login as: root root@192.168.0.30's password: Last login: Tue Apr 8 13:11:42 2008 from chrisnew lptest:~ # ./funscript.sh -bash: ./funscript.sh: No such file or directory lptest:~ # Thanks Christine. |
depending on how you are editing the cron file, you might need to restart the crond service so that it re-reads the contab file.
if you use crontab -e to edit that will restart the crond service automatically IF you change the file. If you are simply vi root (ie: roots crontab file) then you would need to restart the crond service: service crond restart |
Hi DotHQ
I missed your thread. Yes, I use crontab -e when ever I modify the file. Thank you, I didn't realize that it will restart when using this, so we've eliminated one possible issue. Thanks |
All times are GMT -5. The time now is 12:38 PM. |