LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Other *NIX Forums > Solaris / OpenSolaris
User Name
Password
Solaris / OpenSolaris This forum is for the discussion of Solaris, OpenSolaris, OpenIndiana, and illumos.
General Sun, SunOS and Sparc related questions also go here. Any Solaris fork or distribution is welcome.

Notices


Reply
  Search this Thread
Old 07-29-2005, 04:06 AM   #1
twantrd
Senior Member
 
Registered: Nov 2002
Location: CA
Distribution: redhat 7.3
Posts: 1,440

Rep: Reputation: 52
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
 
Old 07-29-2005, 07:55 AM   #2
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
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.
 
Old 07-29-2005, 06:10 PM   #3
twantrd
Senior Member
 
Registered: Nov 2002
Location: CA
Distribution: redhat 7.3
Posts: 1,440

Original Poster
Rep: Reputation: 52
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
 
Old 07-29-2005, 09:24 PM   #4
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
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 ...
 
Old 07-30-2005, 01:11 PM   #5
twantrd
Senior Member
 
Registered: Nov 2002
Location: CA
Distribution: redhat 7.3
Posts: 1,440

Original Poster
Rep: Reputation: 52
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
 
  


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
shell script using /etc/cron.hourly to execute cron.php file? rioguia Programming 3 06-11-2008 08:09 AM
Cron & ksh: Solaris/RHEL 2 incompatibility marist89 Linux - Software 1 01-21-2004 03:48 PM
No mail in Solaris Cron commands markraem Solaris / OpenSolaris 1 01-05-2004 03:11 PM
[cron][mdk9.1]cron deamon seems to ignore some task... yannrichet Linux - Newbie 5 06-26-2003 09:57 AM
How to use cron command in solaris meng_en General 1 11-06-2002 09:08 PM

LinuxQuestions.org > Forums > Other *NIX Forums > Solaris / OpenSolaris

All times are GMT -5. The time now is 08:54 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