LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-03-2008, 09:50 AM   #1
cbannister
LQ Newbie
 
Registered: Apr 2008
Location: Ontario Canada
Posts: 6

Rep: Reputation: 0
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.
 
Old 04-03-2008, 10:02 AM   #2
tailender
LQ Newbie
 
Registered: Oct 2006
Posts: 27

Rep: Reputation: 15
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
 
Old 04-03-2008, 10:36 AM   #3
cbannister
LQ Newbie
 
Registered: Apr 2008
Location: Ontario Canada
Posts: 6

Original Poster
Rep: Reputation: 0
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.
 
Old 04-03-2008, 02:39 PM   #4
cbannister
LQ Newbie
 
Registered: Apr 2008
Location: Ontario Canada
Posts: 6

Original Poster
Rep: Reputation: 0
Unhappy

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 #
 
Old 04-03-2008, 06:41 PM   #5
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,356

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
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

Last edited by chrism01; 04-03-2008 at 06:43 PM.
 
Old 04-07-2008, 07:02 AM   #6
cbannister
LQ Newbie
 
Registered: Apr 2008
Location: Ontario Canada
Posts: 6

Original Poster
Rep: Reputation: 0
Thanks Chris.

I was away on Friday, so I will take a look at this today and let you know.
 
Old 04-08-2008, 01:58 PM   #7
cbannister
LQ Newbie
 
Registered: Apr 2008
Location: Ontario Canada
Posts: 6

Original Poster
Rep: Reputation: 0
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.
 
Old 04-08-2008, 02:04 PM   #8
DotHQ
Member
 
Registered: Mar 2006
Location: Ohio, USA
Distribution: Red Hat, Fedora, Knoppix,
Posts: 548

Rep: Reputation: 33
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
 
Old 04-08-2008, 02:09 PM   #9
cbannister
LQ Newbie
 
Registered: Apr 2008
Location: Ontario Canada
Posts: 6

Original Poster
Rep: Reputation: 0
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
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't get a cron job to run derzok Linux - General 10 12-16-2007 04:00 AM
How to run my cron command ? Tanc Linux - Newbie 6 05-28-2005 04:58 PM
could cron/any batch run at my will sheikhsa Linux - Newbie 2 09-23-2004 08:00 PM
trying to get cron to run naijaguy Linux - General 12 08-18-2004 05:32 PM
how to run this cron job ashley75 Linux - General 5 05-24-2004 11:20 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:52 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration