Solved

Issue with crontab

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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
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 …
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.:

729 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