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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
06-15-2011, 04:15 AM
|
#1
|
|
LQ Newbie
Registered: Jun 2011
Posts: 10
Rep: 
|
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
|
|
|
|
06-15-2011, 07:45 AM
|
#2
|
|
LQ 5k Club
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian Squeeze (server), Slackware 13.37 (netbook), Slackware64 14.0 (desktop),
Posts: 8,357
|
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.
|
06-15-2011, 07:55 AM
|
#3
|
|
LQ Newbie
Registered: Jun 2011
Posts: 10
Original Poster
Rep: 
|
/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.
|
|
|
|
06-15-2011, 08:06 AM
|
#4
|
|
LQ 5k Club
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian Squeeze (server), Slackware 13.37 (netbook), Slackware64 14.0 (desktop),
Posts: 8,357
|
Quote:
Originally Posted by ovidiu84
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.
|
06-15-2011, 08:10 AM
|
#5
|
|
LQ Newbie
Registered: Jun 2011
Posts: 10
Original Poster
Rep: 
|
Quote:
Originally Posted by catkin
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.
|
|
|
|
06-15-2011, 08:22 AM
|
#6
|
|
LQ 5k Club
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian Squeeze (server), Slackware 13.37 (netbook), Slackware64 14.0 (desktop),
Posts: 8,357
|
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
|
|
|
|
06-15-2011, 08:25 AM
|
#7
|
|
LQ Newbie
Registered: Jun 2011
Posts: 10
Original Poster
Rep: 
|
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.
|
|
|
|
06-15-2011, 08:27 AM
|
#8
|
|
LQ 5k Club
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian Squeeze (server), Slackware 13.37 (netbook), Slackware64 14.0 (desktop),
Posts: 8,357
|
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
|
|
|
|
06-15-2011, 08:29 AM
|
#9
|
|
LQ Newbie
Registered: Jun 2011
Posts: 10
Original Poster
Rep: 
|
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.
|
|
|
|
06-15-2011, 08:32 AM
|
#10
|
|
LQ 5k Club
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian Squeeze (server), Slackware 13.37 (netbook), Slackware64 14.0 (desktop),
Posts: 8,357
|
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.
|
|
|
|
06-15-2011, 08:35 AM
|
#11
|
|
LQ Newbie
Registered: Jun 2011
Posts: 10
Original Poster
Rep: 
|
Quote:
Originally Posted by catkin
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 
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 04:13 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|