Linux - NewbieThis 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.
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.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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
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.
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
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
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.
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 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."
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.