The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Grep command is not working when put into cron thiru_cs Shell Programming and Scripting 5 08-06-2008 06:39 AM
sudo chmod not working Movomito UNIX for Advanced & Expert Users 1 06-05-2008 03:41 AM
Cron job not working dkranes UNIX for Dummies Questions & Answers 5 10-26-2007 12:01 PM
cron not working DaleCabell UNIX for Dummies Questions & Answers 1 07-28-2006 08:16 PM
CRON - How to tell it's working? jaffy1229 UNIX for Dummies Questions & Answers 7 04-15-2002 01:09 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 12-17-2008
WhotheWhat WhotheWhat is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 10
Sudo command not working with cron job.

Hello,

I have written a script that has a sudo command to change file permissions within it.

When I run the script manually, the sudo command inside of it works fine.

When the script is run through crontab I get the error "cron: not found".

It the same user profile that I am using to run the script manually that is running the cron jobs.

Any ideas on how to fix this would be greatly appreiciated.

Thanks.
  #2 (permalink)  
Old 12-17-2008
melias melias is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 43
are you able to provide details of the script you're running via cron?
  #3 (permalink)  
Old 12-18-2008
WhotheWhat WhotheWhat is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 10
Quote:
Originally Posted by melias View Post
are you able to provide details of the script you're running via cron?
What details would you nedd?

The jist of it is it uses the sudo command to change the permissions of a file, making it writable, then empties the contents of said file (cat > /dev/null).

So without the sudo command, the file cannot be emptied.
  #4 (permalink)  
Old 12-18-2008
flakblas flakblas is offline
Registered User
  
 

Join Date: Dec 2008
Posts: 13
In general 'sudo' in a cron script is a bad idea. Also, in your scripts are you using the full path/command? You should do that. Are you cable to just install the job under root?
  #5 (permalink)  
Old 12-18-2008
WhotheWhat WhotheWhat is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 10
Quote:
Originally Posted by flakblas View Post
In general 'sudo' in a cron script is a bad idea. Also, in your scripts are you using the full path/command? You should do that. Are you cable to just install the job under root?
Yes, the full path is being used.

No, I cannot install it under root.
  #6 (permalink)  
Old 12-18-2008
bakunin bakunin is offline Forum Staff  
Bughunter Extraordinaire
  
 

Join Date: May 2005
Location: In the leftmost byte of /dev/kmem
Posts: 1,641
Quote:
Originally Posted by WhotheWhat View Post
When the script is run through crontab I get the error "cron: not found".
Sounds like the "Cron Error Number 1" to me: read here how to get over that.

I hope this helps.

bakunin
  #7 (permalink)  
Old 12-18-2008
WhotheWhat WhotheWhat is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 10
Quote:
Originally Posted by bakunin View Post
Sounds like the "Cron Error Number 1" to me: read here how to get over that.

I hope this helps.

bakunin
So to see if this is the case, I need to copy the "PATH=" variable from the env file into my script?

Sorry if this was answered in the link you supplied, but I am a beginner with unix and am not sure what the resolution was that was provided.

Thanks.
Closed Thread

Bookmarks

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 08:22 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0