Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Coder's Corner Lounge (http://www.programmingforums.org/forum11.html)
-   -   Weird .Cron Error (Too lazy to sign up for a Linux forum) (http://www.programmingforums.org/showthread.php?t=14301)

Sane Oct 30th, 2007 4:18 PM

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?

:yawn:

MiKuS Oct 30th, 2007 6:09 PM

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...

titaniumdecoy Oct 30th, 2007 6:19 PM

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


Sane Oct 30th, 2007 8:48 PM

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?

titaniumdecoy Oct 30th, 2007 10:30 PM

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?

Sane Oct 31st, 2007 12:13 AM

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!

MiKuS Oct 31st, 2007 12:41 AM

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/

Sane Oct 31st, 2007 6:51 AM

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

... ...

glimmy Oct 31st, 2007 9:06 AM

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.

DaWei Oct 31st, 2007 9:38 AM

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. :icon_rolleyes:


All times are GMT -5. The time now is 3:23 AM.

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