BSD Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsBSD Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old September 25th, 2002, 09:30 AM
elysium elysium is offline
Gentleman of leisure
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2002
Location: Sweden
Posts: 44 elysium User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 31 m
Reputation Power: 7
Cron isn't executing all commands

I have a script, daily.sh, that runs every day at 3 am
Code:
0 3 * * *      /root/daily.sh

When executed normally (./daily.sh) it works just fine. The problem is that when run by cron, it doesn't execute all of the commands in daily.sh. Even though cron is run by root.

Code:
[root@utopia.XXXXXXX.XX] ~: cat daily.sh
#!/bin/sh
TS=`date "+%Y_%m_%d"`
MYSQL_PATH="/var/db/mysql"
WWW_PATH="/www"

# This part is NOT being executed
umount /dev/da0c
dd if=/dev/zero of=/dev/da0 count=2
disklabel -Brw da0 auto
newfs /dev/da0c >> /dev/null
mount /dev/da0c /zip
# This part is NOT being executed

# This part IS being executed
`cp -R -p $MYSQL_PATH /zip/$TS-mysql`
# .. and a bunch of other cp's.
# This part IS being executed

I don't have anything in /var/cron/deny, and /var/log/cron doesn't say anything useful. Any ideas?

Reply With Quote
  #2  
Old September 25th, 2002, 12:50 PM
mezz mezz is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2001
Posts: 310 mezz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Try to add root like this..
Code:
0	3	*	*	*	root	/root/daily.sh

Reply With Quote
  #3  
Old September 25th, 2002, 02:08 PM
elysium elysium is offline
Gentleman of leisure
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2002
Location: Sweden
Posts: 44 elysium User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 31 m
Reputation Power: 7
Cron took the "root /root/daily.sh"-part as one command, which, obviously, didn't work.

Reply With Quote
  #4  
Old September 26th, 2002, 11:59 AM
StealthElephant's Avatar
StealthElephant StealthElephant is offline
Shes dancing (obviously)
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jul 2002
Location: the far side
Posts: 526 StealthElephant User rank is Corporal (100 - 500 Reputation Level)StealthElephant User rank is Corporal (100 - 500 Reputation Level)StealthElephant User rank is Corporal (100 - 500 Reputation Level)StealthElephant User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 2 h 14 m 22 sec
Reputation Power: 8
is the file system in use when it tried to ge umounted?
__________________

microsofts butterfly is their way off telling u their systems have a **** load of buggs
Advocating Linux Guide
Lesbian Linux
Great & Practical Computer Books

like the links?

Reply With Quote
  #5  
Old September 26th, 2002, 12:20 PM
elysium elysium is offline
Gentleman of leisure
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2002
Location: Sweden
Posts: 44 elysium User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 31 m
Reputation Power: 7
Nope.

Reply With Quote
  #6  
Old October 4th, 2002, 10:18 AM
hertz hertz is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: Melbourne
Posts: 4 hertz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
It's probably got to do with the environment that cron makes available to your script. Try running /usr/bin/env from the command line and see what the environment looks like. Then run the same command using cron. It's likely that the PATH in the cron environment is very different from the one you get on the command line.

For example, my command line PATH is:
/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/X11R6/bin

And my cron PATH is:
/usr/bin:/bin

Most of the commands in the section of your code that isn't executing are in /sbin/.

Hope that helps.

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsBSD Help > Cron isn't executing all commands


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate 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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway