The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
Google UNIX.COM


UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Cron issue kingdbag SUN Solaris 5 07-10-2008 08:14 AM
Another Cron issue. Beefy UNIX for Dummies Questions & Answers 2 03-13-2008 10:30 AM
FTP Cron Issue edua Shell Programming and Scripting 7 11-27-2007 12:30 AM
Issue with cron job -Please help bsandeep_80 Shell Programming and Scripting 6 07-27-2007 11:20 AM
Issue with cron job nattynatty Shell Programming and Scripting 1 11-21-2005 04:37 PM

Closed Thread
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 08-15-2002
flim flam flamma jamma
 

Join Date: May 2001
Location: Chicago IL, USA
Posts: 1,006
cron issue

user x has a cron job that looks in a dir and moves teh files from 1 name to another except its not working correctly.

Code:
. /user/.profile   # sorce the users profile

for file in `ls`; do
mv $file $file.`date +%Y%m%d%H%M%S``microsec`
done
microsec is a binary with 555 perm. on it in /usr/local/bin.

/usr/local/bin IS in the users path && from a shell prompt as that user i can run microsec and it will display the microseconds.

when i run the script by hand everything works. but when it runs via cron the file will get the date but not the microsec.

any hints?
Forum Sponsor
  #2  
Old 08-15-2002
RTM's Avatar
RTM RTM is offline
Hog Hunter
 
Join Date: Apr 2002
Location: On my motorcycle
Posts: 3,039
Hint 1: user X does not have /usr/local/bin in their PATH
  #3  
Old 08-15-2002
Registered User
 

Join Date: Jun 2002
Location: Amsterdam (Netherlands)
Posts: 142
maybe

When you load the .profile can be handy top point to the users homne directory by using ~<username>/.profile

in this case u are sure the right profile is loaded

when a script is NOT working in the cron BUT it does by hand, the problem is mostly a envirnment problem.

so use instead

. /user/.profile # sorce the users profile

~x/.profile Where X is the username
  #4  
Old 08-15-2002
auswipe's Avatar
Registered User
 

Join Date: Nov 2001
Location: Wide Awake Wylie, Texas
Posts: 536
Why not just use the full path to microsec in the cronjob?

That way, you don't have to worry about pathing for the individual user and if the cronjob is ever moved to another user, you are still good to go. And if another admin has to work with this cronjob, the placement of microsec is obvious.
__________________
Not quite as cool as all the other Kids...
  #5  
Old 08-15-2002
flim flam flamma jamma
 

Join Date: May 2001
Location: Chicago IL, USA
Posts: 1,006
you know what really makes me mad. when people over write a profile on an account they are NOT supposed to use.

i guess its my error for not double checking the PATH. ;/

its working liek it should now (after i fixed the path)
  #6  
Old 08-26-2002
Kelam_Magnus's Avatar
Registered User
 

Join Date: Aug 2001
Location: DFW McKinney, TX,
Posts: 1,069
/agree Auswipe full path is always best

I must reluctantly agree with Auswipe. hehehe

It is a good practice and good security to ALWAYS use the full path in any cron entry and in the scripts that you write.

The reason for this is, it is a very easy way for someone to replace any binary on your system with a trojan.

Always use full path AND always keep a backup copy of crontab for all users that have one especially cron.

__________________
My brain is your brain
Google The UNIX and Linux Forums
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 02:14 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0