LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Solaris / OpenSolaris (https://www.linuxquestions.org/questions/solaris-opensolaris-20/)
-   -   cp in cron - solaris (https://www.linuxquestions.org/questions/solaris-opensolaris-20/cp-in-cron-solaris-347941/)

twantrd 07-29-2005 04:06 AM

cp in cron - solaris
 
Hi,

I have a rather strange problem. I put a cp command in cron but it doesn't copy the file. I put the same command under cron in a debian box and it works fine. My command in cron is:

53 1 * * 5 (cd /blah; cp fd_test.xml fd_twantrd.xml) >> /var/cron/log 2>&1

So, this runs at 1:53am on only Fridays and copies fd_test.xml to fd_twantrd.xml. This crontab is under a normal user (not root). If I log in as that user's account and run the command it's fine. But if it's in cron, it just won't copy the file.

Is it a solaris thing? A bit stumped. I could write a script to do this but I'd rather find the problem rather than come up with a workaround. This should be very simple to do. If it helps, this is on solaris 7. Thanks..

-twantrd

jlliagre 07-29-2005 07:55 AM

Anything interesting in /var/cron/log ?
and before that, is the normal user allowed to write on that log file ?
It shouldn't anyway, you'd rather use a custom file for your user's cron logs.

twantrd 07-29-2005 06:10 PM

Hi Jlliagre,

Nothing interseting in the logs:

> CMD: (cd /blah; cp fd_friday.xml fd_twantrd.xml) >> /var/cron/log 2
>&1
> webadmin 4288 c Fri Jul 29 01:22:00 2005
< webadmin 4288 c Fri Jul 29 01:22:00 2005 rc=1

That's all it says. And no, the user cannot write to the log file - but does that really matter?
I'm so stumped as to why cron doesn't copy the file...hmm.

-twantrd

jlliagre 07-29-2005 09:24 PM

Quote:

That's all it says. And no, the user cannot write to the log file - but does that really matter?
I believe it does really matter.

This is my guess:

Before running the command, cron has first to manage its input and output files, and as you wrote, it cannot open stdout nor stderr !
Why do you want cron bothering go further ... it simply fails, and is prevented to tell it to you by this foolish redirection ...

twantrd 07-30-2005 01:11 PM

I just wanted cron to redirect output to a cron log file for examination if something happened. I'll take the route that you mentioned - saving it a file that the user can write to. Yes, you were correct. Once I took out ">> /var/cron/log" in the cron entry, it worked. Thanks for your help. Just learned something new.

-twantrd


All times are GMT -5. The time now is 10:03 AM.