Solved

Issue with crontab

Posted on 2011-09-13
4
447 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

When you do backups in the Solaris Operating System, the file system must be inactive. Otherwise, the output may be inconsistent. A file system is inactive when it's unmounted or it's write-locked by the operating system. Although the fssnap utility…
My previous tech tip, Installing the Solaris OS From the Flash Archive On a Tape (http://www.experts-exchange.com/articles/OS/Unix/Solaris/Installing-the-Solaris-OS-From-the-Flash-Archive-on-a-Tape.html), discussed installing the Solaris Operating S…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
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.

820 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