Solved

Issue with crontab

Posted on 2011-09-13
4
457 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
I promised to write further about my project, and here I am.  First, I needed to setup the Primary Server.  You can read how in this article: Setup FreeBSD Server with full HDD encryption (http://www.experts-exchange.com/OS/Unix/BSD/FreeBSD/A_3660-S…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
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.:
Suggested Courses

734 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