LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 07-10-2004, 10:07 AM   #1
bjdea1
Member
 
Registered: Oct 2003
Posts: 37

Rep: Reputation: 15
root cron permissions question


Hi,
I've got a cron setup under user root. The cron writes to a file and does a few other things. The thing is no matter what chmod I set the directory (which happens to be /root/test/) the script is contained in, and no matter how I chmod the script itself and the file it reads and writes, I just can't get the script running under root cron to write to the file. When I run the script myself manually it works fine - it writes to the file and there is no problem. But when the cron executes the script it won't write to the file.

I edit the cron file logged in as root user and using command "crontab -e"

As far as I know I am doing everything right - does anyone know why when executed by the cron the script fails to write to the file?

Thanks
 
Old 07-10-2004, 10:30 AM   #2
wolfe2554
Member
 
Registered: Apr 2003
Location: denver co
Distribution: redhat9
Posts: 156

Rep: Reputation: 30
have you checked the path directory. as when you are logged in as root the path is set. but when cron runs it does not run the /root/.bashrc and profile. try modifing the script to say /root/test/whatever. instead of whatever.
thanxs
wolfe
 
Old 07-10-2004, 10:47 AM   #3
bjdea1
Member
 
Registered: Oct 2003
Posts: 37

Original Poster
Rep: Reputation: 15
yep

thanks for responding, but I have it already set with /root/test/

It seems to be something else, any other ideas?
 
Old 07-10-2004, 10:52 AM   #4
wolfe2554
Member
 
Registered: Apr 2003
Location: denver co
Distribution: redhat9
Posts: 156

Rep: Reputation: 30
ok so you have this script that will not run from cron. check your crontab
make sure the path is right and that the file in /etc/crond.daily/whatever is right to run the script. if all of these are correct then it should run just fine. but when cron runs the program as root it uses that path in the crontab to run it. also you could just put the script in cron.daily or monthy or whatever. cron just runs whatever is in that dir.
wolfe
 
Old 07-10-2004, 11:03 AM   #5
bjdea1
Member
 
Registered: Oct 2003
Posts: 37

Original Poster
Rep: Reputation: 15
ok

thanks again for offering your thoughts. The cron does execute the script, I get emails telling me it worked. It just doesn't seem to be running as root user. Its like another user is running it and because of that when the script runs it can't open any files or write any files.

The cron is not the "daily", "weekly" ones its the ones in /var/spool/cron . This is the directory where all users on the server have their own crons running, one of the users is "root", when I am logged in as root user (using su command) I type "crontab -e" and edit the root cron in this directory. I need to run the cron every minute, its a process monitoring script that contantly checks for runaway processes and also checks services are running.

Maybe crons in the /var/spool/cron directory just can't run root crons? If nott how could I setup a root cron to run every minute by another method?

Thanks
 
Old 07-10-2004, 11:22 AM   #6
bjdea1
Member
 
Registered: Oct 2003
Posts: 37

Original Poster
Rep: Reputation: 15
ok found problem - sorry you were right

Ok,
sorry I found the cause. I have the main config file being accessed as "./config.file". No wonder everything else is failing because this config file is not being read at the very start of the program. Sorry I should have checked this more, thanks for your help.
 
Old 07-10-2004, 12:39 PM   #7
wolfe2554
Member
 
Registered: Apr 2003
Location: denver co
Distribution: redhat9
Posts: 156

Rep: Reputation: 30
it's always the that little detail that cause me to turn red too.
lol
wolfe
oh bye the way check my post about a boot disk ext2resize
I have no idea
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Windows partition requires root permissions- chmod question Garibaldi3489 Slackware 19 05-16-2005 01:52 AM
n00b question: Problems with linux root permissions and ntfs partition wLancer Linux - General 4 12-06-2004 04:32 PM
Permissions in cron esasse Linux - Newbie 4 11-25-2004 07:00 AM
Cron is not available as non-root linuxfond Linux - Newbie 5 02-28-2003 12:29 PM
Cron sending mail to root bspicer Linux - General 2 05-01-2002 12:52 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 08:50 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration