LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 06-15-2011, 04:15 AM   #1
ovidiu84
LQ Newbie
 
Registered: Jun 2011
Posts: 10

Rep: Reputation: Disabled
Unhappy Cron JOB won't run - Slackware 12.1


I've checked most of the treads that address this problem on this forum but nothing works for me. With the same configuration the same script runs on debian / ubuntu / centos / redhat servers. But it won't run on Slackware.

Code:
#!/bin/sh

/opt/backup/apache-ant-1.7.1/bin/ant -file /opt/backup/run/full.xml
This is the script ( full path included )

This is the cron config:
Code:
root@ums:/opt/backup/run# cat /var/spool/cron/crontabs/root
# If you don't want the output of a cron job mailed to you, you have to direct
# any output to /dev/null.  We'll do this here since these jobs should run
# properly on a newly installed system, but if they don't the average newbie
# might get quite perplexed about getting strange mail every 5 minutes. :^)
#
# Run the hourly, daily, weekly, and monthly cron jobs.
# Jobs that need different timing may be entered into the crontab as before,
# but most really don't need greater granularity than this.  If the exact
# times of the hourly, daily, weekly, and monthly cron jobs do not suit your
# needs, feel free to adjust them.
#
# Run hourly cron jobs at 47 minutes after the hour:
47 * * * * /usr/bin/run-parts /etc/cron.hourly 1> /dev/null
#
# Run daily cron jobs at 4:40 every day:
40 4 * * * /usr/bin/run-parts /etc/cron.daily 1> /dev/null
#
# Run weekly cron jobs at 4:30 on the first day of the week:
30 4 * * 0 /usr/bin/run-parts /etc/cron.weekly 1> /dev/null
#
# Run monthly cron jobs at 4:20 on the first day of the month:
20 4 1 * * /usr/bin/run-parts /etc/cron.monthly 1> /dev/null

55 23 * * * /opt/backup/run/run.sh
I've also tried without the .sh extension, have a "run" script.

The script runs perfect manually. Also there are entries in the cron log

Code:
Jun 12 18:47:01 ums crond[3202]: USER root pid 10241 cmd /usr/bin/run-parts /etc/cron.hourly 1> /dev/null
Jun 12 19:47:01 ums crond[3202]: USER root pid 10243 cmd /usr/bin/run-parts /etc/cron.hourly 1> /dev/null
Jun 12 20:47:01 ums crond[3202]: USER root pid 10245 cmd /usr/bin/run-parts /etc/cron.hourly 1> /dev/null
Jun 12 21:47:01 ums crond[3202]: USER root pid 10247 cmd /usr/bin/run-parts /etc/cron.hourly 1> /dev/null
Jun 12 22:14:01 ums crond[3202]: USER root pid 10249 cmd /opt/backup/run/run.sh
I'm totally baffled by this, I've been doing the backups manually for 3 weeks now, I really need to make this run

I've also tried forwarding the output to a log file .. nothing
 
Old 06-15-2011, 07:45 AM   #2
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,551
Blog Entries: 28

Rep: Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176
Silly question but is the script /opt/backup/run/run.sh?

Have you tried changing the script to something very simple like
Code:
#!/bin/sh
echo running > /tmp/XXX.$$
Have you tried changing the shebang line to #!/bin/bash ?
 
1 members found this post helpful.
Old 06-15-2011, 07:55 AM   #3
ovidiu84
LQ Newbie
 
Registered: Jun 2011
Posts: 10

Original Poster
Rep: Reputation: Disabled
/var/log/cron entry

Code:
Jun 15 15:39:01 ums crond[3200]: USER root pid 20541 cmd /opt/backup/run/run.sh
Jun 15 15:39:01 ums crond[3200]: USER root pid 20542 cmd /opt/backup/run/temp.sh
crontab
Code:
root@ums:/opt/backup# crontab -l root
# If you don't want the output of a cron job mailed to you, you have to direct
# any output to /dev/null.  We'll do this here since these jobs should run
# properly on a newly installed system, but if they don't the average newbie
# might get quite perplexed about getting strange mail every 5 minutes. :^)
#
# Run the hourly, daily, weekly, and monthly cron jobs.
# Jobs that need different timing may be entered into the crontab as before,
# but most really don't need greater granularity than this.  If the exact
# times of the hourly, daily, weekly, and monthly cron jobs do not suit your
# needs, feel free to adjust them.
#
# Run hourly cron jobs at 47 minutes after the hour:
47 * * * * /usr/bin/run-parts /etc/cron.hourly 1> /dev/null
#
# Run daily cron jobs at 4:40 every day:
40 4 * * * /usr/bin/run-parts /etc/cron.daily 1> /dev/null
#
# Run weekly cron jobs at 4:30 on the first day of the week:
30 4 * * 0 /usr/bin/run-parts /etc/cron.weekly 1> /dev/null
#
# Run monthly cron jobs at 4:20 on the first day of the month:
20 4 1 * * /usr/bin/run-parts /etc/cron.monthly 1> /dev/null

39 15 * * * /opt/backup/run/run.sh

39 15 * * * /opt/backup/run/temp.sh
temp.sh
Code:
#!/bin.sh

echo running > /opt/temp.log
file wasn't created ...


I've also tried with #!/bin/bash. Nothing.

EDIT: I've made an error in the temp script (#!/bin.sh instead of #!/bin/bash or #!/bin/sh ). Yes the temp log was created. But my script didn't run.

Last edited by ovidiu84; 06-15-2011 at 08:06 AM.
 
Old 06-15-2011, 08:06 AM   #4
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,551
Blog Entries: 28

Rep: Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176
Quote:
Originally Posted by ovidiu84 View Post
Code:
#!/bin.sh

echo running > /opt/temp.log
file wasn't created ...


I've also tried with #!/bin/bash. Nothing.
Typo: #!/bin.sh for #!/bin/sh but if you got #!/bin/bash right that's not the issue. You could try increasing cron of crond (depending on which cron system you have) logging level. Details in cron or crond man page.

Last edited by catkin; 06-15-2011 at 08:06 AM. Reason: missing word
 
1 members found this post helpful.
Old 06-15-2011, 08:10 AM   #5
ovidiu84
LQ Newbie
 
Registered: Jun 2011
Posts: 10

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by catkin View Post
Typo: #!/bin.sh for #!/bin/sh but if you got #!/bin/bash right that's not the issue. You could try increasing cron of crond (depending on which cron system you have) logging level. Details in cron or crond man page.
yes, made the correction and made the output but the run.sh script still didn't do anything. any ideas how i can change the logging lvl in cron ? i'm not at all used to slackware, can't find his services or auto run

EDIT: NVM , logging lvl is at 8

Code:
root@ums:/opt/backup/backups# crond --help
dcron 2.3.3
dcron -d [#] -l [#] -S -L logfile -f -b -c dir
-d num  debug level
-l num  log level (8 - default)
-S      log to syslod (defualt)
-L file log to file
-f      run in fordeground
-b      run in background (default)
-c dir  working dir
root@ums:/opt/backup/backups# ps -aux | grep crond
Warning: bad ps syntax, perhaps a bogus '-'? See http://procps.sf.net/faq.html
root      3200  0.0  0.0   1908   656 ?        S    Jun14   0:00 /usr/sbin/crond -l8
root     20643  0.0  0.0   2060   660 pts/1    S+   15:58   0:00 grep crond

Last edited by ovidiu84; 06-15-2011 at 08:13 AM.
 
Old 06-15-2011, 08:22 AM   #6
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,551
Blog Entries: 28

Rep: Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176
Assuming Slackware 12.1 is like 13.1:
Code:
pkill crond
/usr/sbin/crond -l8 >>/var/log/cron 2>&1
The second command is based on the comment in /etc/rc.d/rc.M
 
Old 06-15-2011, 08:25 AM   #7
ovidiu84
LQ Newbie
 
Registered: Jun 2011
Posts: 10

Original Poster
Rep: Reputation: Disabled
This is the ... I just don't understand, I've found out why, seems I've overlooked a simple thing

the script runs manually from command line without problems and

Code:
root@ums:/opt/backup/backups# echo $JAVA_HOME
/usr/lib/java
But for some reasons, don't know which, the variable doesn't exist for the "enviroment" where cron runs

Code:
root@ums:/opt/backup/backups# ps aux | grep crond
root      3200  0.0  0.0   1908   656 ?        S    Jun14   0:00 /usr/sbin/crond -l8
root     20815  0.0  0.0   2060   660 pts/1    S+   16:13   0:00 grep crond
So cron runs as root, so the tasks should run as root right ? But when the script runs it tells me it can't find JAVA_HOME :/.

I've modified the script and added a
Code:
export JAVA_HOME=/usr/lib/java
It works now. Thanks.

Last edited by ovidiu84; 06-15-2011 at 08:27 AM.
 
Old 06-15-2011, 08:27 AM   #8
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,551
Blog Entries: 28

Rep: Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176
So crond is already running with loglevel 8.

Have you checked root's mail?

You could try a crontab entry like
Code:
* * * * * echo foo > /tmp/cron.foo.log 2>&1
 
Old 06-15-2011, 08:29 AM   #9
ovidiu84
LQ Newbie
 
Registered: Jun 2011
Posts: 10

Original Poster
Rep: Reputation: Disabled
Since the script runs ok manually, and does indeed depend on JAVA_HOME, which I had set. I assumed it should be ok for cron too. But I've never checked, I use the same config on some debian / centos boxes and never had a hitch like this.
 
Old 06-15-2011, 08:32 AM   #10
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,551
Blog Entries: 28

Rep: Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176
Glad you found a solution

I don't understand why temp.sh didn't produce /opt/temp.log though; that has nothing to do with Java.

cron sets a limited environmemt. If you want the same environment as when logged on, add -l (letter l) to the shebang line; that makes the shell simulate a logon.

Threads can be marked SOLVED via the Thread Tools menu.
 
Old 06-15-2011, 08:35 AM   #11
ovidiu84
LQ Newbie
 
Registered: Jun 2011
Posts: 10

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by catkin View Post
Glad you found a solution

I don't understand why temp.sh didn't produce /opt/temp.log though; that has nothing to do with Java.

cron sets a limited environmemt. If you want the same environment as when logged on, add -l (letter l) to the shebang line; that makes the shell simulate a logon.

Threads can be marked SOLVED via the Thread Tools menu.
I had mentioned in my reply that after correcting the #/bin.bash into #!/bin/bash it worked "EDIT: I've made an error in the temp script (#!/bin.sh instead of #!/bin/bash or #!/bin/sh ). Yes the temp log was created. But my script didn't run."

Thanks for the assistance
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Run cron job in every 20 second ust Linux - Newbie 12 09-22-2008 11:04 PM
Can't get a cron job to run derzok Linux - General 10 12-16-2007 04:00 AM
Backup script won't run in cron job. Why? Micro420 Linux - General 19 10-31-2007 08:26 PM
Did my Cron job run? ryedunn Linux - Newbie 2 02-25-2004 08:59 AM
Cron job does not run brentos Linux - General 6 12-12-2003 02:37 PM


All times are GMT -5. The time now is 10:38 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration