Help - Search - Members - Calendar
Full Version: cron file writing permission problem
Linuxhelp > Support > Technical Support
TheGuyGuy
In cron, I execute:

*/1 * * * * echo "hello" > $HOME/hello

...and in e-mail I get a permission error:

/bin/sh: line 1: [my home path]/hello: Permission denied

Why?

Similarly, I run a perl script in cron (instead of redirecting output from a command), and in the perl script, I try both redirecting STDOUT to a file and simply opening a file for write, and I also get a "Permission denied".

I check the user ID and the group ID, both in cron and in the perl script, and they are normal (my user ID and group ID). (I am not root.)

I run the script in the shell and it works like a charm (and of course echo works, too). No, I don't use any weirdo environment variables in the script.

It kind of baffles my mind how the result can be different if the uid and gid are the same.

I am not using setuid or anything of that nature to my knowledge.

The server is a RedHat Enterprise 3.0 server running on an i686 chip of some kind.

I haven't the foggiest what is going on, but it's pretty aggravating. Thanks for any help,

TheGuyGuy
markjr
QUOTE (TheGuyGuy @ Jul 30 2006, 10:15 PM) *
In cron, I execute:

*/1 * * * * echo "hello" > $HOME/hello

...and in e-mail I get a permission error:

/bin/sh: line 1: [my home path]/hello: Permission denied

Why?


Off the top of my head, I'm guessing $HOME isn't set in your crontab environment.

Try this:

*/1 * * * * echo "home is:$HOME"; echo "hello" > $HOME/hello

and see what shows up for $HOME in your email error report
TheGuyGuy
QUOTE (markjr @ Jul 30 2006, 11:33 PM) *
Off the top of my head, I'm guessing $HOME isn't set in your crontab environment.

Try this:

*/1 * * * * echo "home is:$HOME"; echo "hello" > $HOME/hello

and see what shows up for $HOME in your email error report


Result is:

home is:[my home directory -- which I am censoring]
[again my home directory]/hello: Permission denied.

It's set.

TheGuyGuy
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2017 Invision Power Services, Inc.