Solved

Issue with crontab

Posted on 2011-09-13
4
427 Views
Last Modified: 2012-06-21
My friend executated a script to show all the daily logs. Everytime the script is executated from the crontab ,a file is created but remains empty.

On the other hand, when the same script is executated  manually, all the daily logs appear in the output

the os is solaris
0
Comment
Question by:cismoney
4 Comments
 
LVL 68

Assisted Solution

by:woolmilkporc
woolmilkporc earned 250 total points
ID: 36531203
Please use full paths to all executables, in crontab as well as in the called script.

And please be aware that cron does not run shell initialization profiles, so there is no PATH except for /usr/bin and there are no environment variables except for a few things like HOME, SHELL etc.

wmp
0
 
LVL 16

Expert Comment

by:Bryan Butler
ID: 36531236
Can you post the script?  Are you adding it to the default user?  Usually it's the need for fully qualified pathnames.  Cron runs under it's own shell with it's own paths and environment vars.
0
 
LVL 11

Expert Comment

by:jgiordano
ID: 36531237
as woolmilkporc said make sure full paths and you should source specific profiles if needed.
0
 
LVL 6

Accepted Solution

by:
Tomunique earned 250 total points
ID: 36536265
When you say "all the daily logs appear in the output"
Does this mean to the screen?  or a file?

If it's to the screen, it could be that some of the output is going to stderr, and appears to be normal output.

To get the data to a file, do you use a redirect (greater than sign)  (/home/dog/script > outputfile)
Or does the script create the output to a file even when you run it from the command line?

I'm thinking if it's to the screen, add a stderr redirect to the file as well.

/home/dog/script  > outputfilename  2>&1

Tom
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello fellow BSD lovers, I've created a patch process for patching openjdk6 for BSD (FreeBSD specifically), although I tried to keep all BSD versions in mind when creating my patch. Welcome to OpenJDK6 on BSD First let me start with a little …
Using libpcap/Jpcap to capture and send packets on Solaris version (10/11) Library used: 1.      Libpcap (http://www.tcpdump.org) Version 1.2 2.      Jpcap(http://netresearch.ics.uci.edu/kfujii/Jpcap/doc/index.html) Version 0.6 Prerequisite: 1.      GCC …
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now