Cron redirect problem


 
Thread Tools Search this Thread
Operating Systems Solaris Cron redirect problem
# 1  
Old 12-09-2009
Cron redirect problem

Hello all,
I have a script that I am trying to execute and redirect the output to a file, but I have trouble in redirection. The cron job is running properly as I see it in the mail.

This is what I am doing
Code:
In crontab file,
0 4 * * * somescript.sh > /some_location/`date '+%m%d%y_%H%M'`.log

What is it that I am doing wrong?
Please help!!
# 2  
Old 12-09-2009
I have no such problem. On Solaris it works.

But try using /usr/bin/date.

Does "some_location" exist? Is it writable by the user running the cronjob?
# 3  
Old 12-09-2009
Does it produce any output to stdout? Maybe add 2>&1 to it's end to catch stdout and stderr.
# 4  
Old 12-09-2009
Its on Solaris itself.

The location is writeable.

I tried running the script and redirecting the output, it works but cannot do it with cron for some reason.

Code:
# ./somescript.sh > /some_location/`date '+%m%d%y_%H%M'`.log is working

@zaxxon,
I tried that too, but of no use.
# 5  
Old 12-09-2009
does

Code:
/var/cron/log

contain some info on this? error messages, whatever..?
# 6  
Old 12-09-2009
There is no error in /var/cron/log. It says the script executed on time.
# 7  
Old 12-09-2009
Seems this could go on for days!

You have to take some initiative. Try something different. Does your script direct the output somewhere else? Does it play around with file descriptors? Did you check your mail? If it's not that sensitive, post the script so we can see what it's doing. Change your cronjob to write to /tmp instead of "some_location". Play around with it a bit.

There's no reason I can think why it shouldn't do what you expect, and from what you've given us it should, but it doesn't help if ypur script can only run at 4 in the morning!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Web Development

Htaccess Redirect Problem

Hi, I have this string that I need to match and redirect to an actual live url. I have tried what I know and it won't match. This is the url I want to match. http://www.abc.com/smf_test/?topic=191.0;wap2 here is my attempt at a pattern match RewriteCond %{REQUEST_URI} ^/smf_test/$... (0 Replies)
Discussion started by: sharingsunshine
0 Replies

2. UNIX for Dummies Questions & Answers

Execution problem with Cron: Script works manually but not w/Cron. Why?

Hello gurus, I am making what I think is a simple db2 call from within a shell script but I am having difficulty producing the desired report when I run the script shown below from a shell script in cron. For example, my script and the crontab file setup is shown below: #!/bin/ksh db2... (3 Replies)
Discussion started by: okonita
3 Replies

3. Shell Programming and Scripting

Problem with << redirect - Please help!

I have a script to send an email like below. Problem is, the if ..fi block is not getting executed, and is coming as a part of the email body. Can anyone take a look at this? :confused: Log file shows this: SEND_MAIL.prog: line 64: : command not found echo "Input Parameters" echo... (11 Replies)
Discussion started by: mansmaan
11 Replies

4. Shell Programming and Scripting

Redirect Problem

Hi, I have perl script which is calling an external command using "system()" with argument. But i am not able to capture the output.Even tried with backtick also with no luck. . . $number=<>; system ("cmd $number >output.txt"); (2 Replies)
Discussion started by: rasingraj
2 Replies

5. Shell Programming and Scripting

redirect stdout and stderr to file wrong order problem with subshell

Hello I read a lot of post related to this topic, but nothing helped me. :mad: I'm running a ksh script with subshell what processing some ldap command. I need to check output for possible errors. #!/bin/ksh ... readinput < $QCHAT_INPUT |& while read -p line do echo $line ... (3 Replies)
Discussion started by: Osim
3 Replies

6. Shell Programming and Scripting

stdout redirect is working buy direct script exec but not in cron

Hi @ all :) i made a very little shell script witch is working well when i'm launching it directly like with ./script but when i'm launching it by cron tab it work at half only. the part of the script witch are not working are: #!/bin/sh apt-get updade apt-get -s upgrade >>... (5 Replies)
Discussion started by: calibal
5 Replies

7. Shell Programming and Scripting

KSH problem - how do i redirect three times?

i need to output an ls command to a file but also capture any errors from that command and output them to a log file and the screen. if it's only possible to output them to a log file and not the screen then that's fine. this is what i've tried so far, but it won't populate log.txt. i've... (16 Replies)
Discussion started by: mjays
16 Replies

8. Shell Programming and Scripting

Script that Redirect SSH output via cron

Hi, I have a script that's being called via a crontab which is a wrapper script that creates a log for the script that gets executed. Within the script that gets executed, it also run's subscripts. I've been able to get everything to work .. but the issue is one of the subscript that goes out... (4 Replies)
Discussion started by: primp
4 Replies

9. Shell Programming and Scripting

Redirect Problem

I am using the time command in a script however the output of the time command will display on my screen but not my output file. Any Ideas on how to fix this? > cat test.sh ############################# #!/usr/bin/sh for COMMAND in pwd do time ${COMMAND} done | sed "s/^/ ... (4 Replies)
Discussion started by: 2dumb
4 Replies

10. UNIX for Advanced & Expert Users

problem with redirect stdout to file

Hi all hope you can help as I am going MAD!!! :eek: The below is in a shell script but the redirection in the sed line does not work and outputs to the screen and the $fname_2 does note get created ????? Can any one help ?? #!/bin/ksh cd /app/ for fname in `ls -1 X*` do sed 1d $fname... (3 Replies)
Discussion started by: mlucas
3 Replies
Login or Register to Ask a Question