Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Oct 30th, 2007, 3:18 PM   #1
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Location: Waterloo, Ontario
Posts: 1,885
Rep Power: 5 Sane will become famous soon enough
Send a message via MSN to Sane
Weird .Cron Error (Too lazy to sign up for a Linux forum)

Too lazy to sign up for a Linux forum...

I'm having a weird issue with cron. The file looks something like:

MAILTO=thisismyaddress
0 0 * * * /home/skiclub/sync/esus -u

When the cron job executes, I get an e-mail indicating that the program esus (which I believe is Java...) started executing... but ran into a permissions error when it attempted to delete/modify a file.

However... if I run the command "/home/skiclub/sync/esus -u" in the same shell, of the same Unix user account, it runs through fine without the permission error.

Why does my cron's shell command have less privileges than the same user's shell command? Doesn't the crontab execute the command just as if it were typed into the shell??

Perhaps the permission error is related to the lack of an included resource? Do I need to specify anything in PATH or SHELL or HOME?

Sane is offline   Reply With Quote
Old Oct 30th, 2007, 5:09 PM   #2
MiKuS
Hobbyist Programmer
 
Join Date: Jun 2007
Posts: 133
Rep Power: 2 MiKuS is on a distinguished road
Re: Weird .Cron Error (Too lazy to sign up for a Linux forum)

what file is it trying to delete/modify? you might need to chmod the file to be writable...
MiKuS is offline   Reply With Quote
Old Oct 30th, 2007, 5:19 PM   #3
titaniumdecoy
Expert Programmer
 
titaniumdecoy's Avatar
 
Join Date: Nov 2005
Posts: 855
Rep Power: 3 titaniumdecoy is on a distinguished road
Send a message via AIM to titaniumdecoy
Re: Weird .Cron Error (Too lazy to sign up for a Linux forum)

Try this:

MAILTO=thisismyaddress
0 0 * * * root /home/skiclub/sync/esus -u
titaniumdecoy is online now   Reply With Quote
Old Oct 30th, 2007, 7:48 PM   #4
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Location: Waterloo, Ontario
Posts: 1,885
Rep Power: 5 Sane will become famous soon enough
Send a message via MSN to Sane
Re: Weird .Cron Error (Too lazy to sign up for a Linux forum)

titanium: If that runs the file under the user root, I don't want that. The program creates files that need to have specific permissions and owner. And I can't shouldn't be modifying the code to change the owner or chmod the files.

Therefore I need it to run the file using the current user... the user who owns the crontab.

But I still don't understand!! Does cron not execute the shell command as if it were typed into the shell by the owner of the crontab? Why does it work if I type it in directly, but not in cron!? That's so frustrating.

I'm reading information about PATH. But I don't understand it. Might there be a path variable that Java needs? How can I check? Why would this matter anyways if it already works in the shell?
Sane is offline   Reply With Quote
Old Oct 30th, 2007, 9:30 PM   #5
titaniumdecoy
Expert Programmer
 
titaniumdecoy's Avatar
 
Join Date: Nov 2005
Posts: 855
Rep Power: 3 titaniumdecoy is on a distinguished road
Send a message via AIM to titaniumdecoy
Re: Weird .Cron Error (Too lazy to sign up for a Linux forum)

Replace root with the username of the user you want the cron to run as.

If you post the error message your Java program is giving you I might be able to help. Also, what linux distro and shell are you using?
titaniumdecoy is online now   Reply With Quote
Old Oct 30th, 2007, 11:13 PM   #6
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Location: Waterloo, Ontario
Posts: 1,885
Rep Power: 5 Sane will become famous soon enough
Send a message via MSN to Sane
Re: Weird .Cron Error (Too lazy to sign up for a Linux forum)

I'm X11ing into Redhat 4.

The error message is the permissions error when it tries to delete/modify.

So by default, what username does a cron run under? As far as I can tell, it has been running under the crontab's user, as it has been for my other cron jobs... which is what I need for this cron job too... so I'm pretty sure it's got the user right. But that would be the same user that it works as a shell command with!
Sane is offline   Reply With Quote
Old Oct 30th, 2007, 11:41 PM   #7
MiKuS
Hobbyist Programmer
 
Join Date: Jun 2007
Posts: 133
Rep Power: 2 MiKuS is on a distinguished road
Re: Weird .Cron Error (Too lazy to sign up for a Linux forum)

you're not using cron tabs properly, read this: http://www.cyberciti.biz/faq/how-do-...-or-unix-oses/
MiKuS is offline   Reply With Quote
Old Oct 31st, 2007, 5:51 AM   #8
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Location: Waterloo, Ontario
Posts: 1,885
Rep Power: 5 Sane will become famous soon enough
Send a message via MSN to Sane
Re: Weird .Cron Error (Too lazy to sign up for a Linux forum)

How is
5 0 * * * /path/to/command

Any different from
0 0 * * * /home/skiclub/sync/esus -u

... ...
Sane is offline   Reply With Quote
Old Oct 31st, 2007, 8:06 AM   #9
glimmy
Programmer
 
glimmy's Avatar
 
Join Date: May 2005
Location: Minnesota
Posts: 42
Rep Power: 0 glimmy is on a distinguished road
Send a message via AIM to glimmy
Re: Weird .Cron Error (Too lazy to sign up for a Linux forum)

Is Java in PATH and is esus executable?

What exactly is the error message?

and is the Esus program compiled or is it a script? You could try throwing in a few statements for debugging.
glimmy is offline   Reply With Quote
Old Oct 31st, 2007, 8:38 AM   #10
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Re: Weird .Cron Error (Too lazy to sign up for a Linux forum)

The OP has stated that the program (esus) runs properly from the command line. He has stated that the error has to do with permissions being violated when he attempts to modify or delete a file. I think that indicates that esus is executable. I don't know why he would want to add debugging statements to it.

Whether or not there's a path difference that has implications when it's run from the command line, versus when cron runs it, I don't know. I don't have a Linux system, either.

Some of the responses are pretty damned silly, though, given the previous information in the thread.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Slackware installation guide for Linux beginners coldDeath Coder's Corner Lounge 104 Jul 29th, 2007 4:40 AM
How many forum members... DaWei Coder's Corner Lounge 33 Jul 17th, 2007 4:55 PM
My views on Linux Marvin Coder's Corner Lounge 70 Dec 19th, 2006 11:13 AM
Linux is Annoying (Ubuntu) Baphomet Coder's Corner Lounge 6 Dec 1st, 2006 8:42 AM
windows memset and Linux memset (difference?) Dr.Backtick` C++ 0 Feb 5th, 2005 7:59 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 3:59 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC