Solved

Issue with crontab

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This tech tip describes how to install the Solaris Operating System from a tape backup that was created using the Solaris flash archive utility. I have used this procedure on the Solaris 8 and 9 OS, and it shoudl also work well on the Solaris 10 rel…
I have been running these systems for a few years now and I am just very happy with them.   I just wanted to share the manual that I have created for upgrades and other things.  Oooh yes! FreeBSD makes me happy (as a server), no maintenance and I al…
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 navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

747 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

12 Experts available now in Live!

Get 1:1 Help Now