- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Script Execution Unable to Log When Executed V...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2010 12:37 AM
01-12-2010 12:37 AM
Did some minor troubleshooting:
1. Checked the user that executes the job if he is a member of the cron.allow file.
2. Checked Directory Permissions
3. Changed the default shell of the user from /usr/bin/sh to /sbin/sh
4. Placed an ampersand "&" at the end of the script in crontab (e.g.: * * * * * /dir/script.sh &)
But to no avail. What seems to be the problem with cron?
TIA
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2010 12:57 AM
01-12-2010 12:57 AM
Solutioncan you please sahre the O/ps of the job as run maunally as well as the error that you get while executing the job as with cron.
the cron logs you can find at /var/adm/cron/log file.
please share as well the O/p of the command
crontab -e as run as root
regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2010 01:08 AM
01-12-2010 01:08 AM
Re: Script Execution Unable to Log When Executed Via Cron
I placed several lines inside my scripts to echo everything that it does to a file. There are actually two parts of the script logging. 1st part it logs the date, time of execution. 2nd part it logs several select commands to the DB.
The log looks like this when executed manually:
===> START Tue Jan 12 04:30:00 EAT 2010
Date From:
Date To:
Processing DM ACR
Interactive mode off.
(1 row affected)
Create table tempdb..XXX_ACR
(0 rows affected)
Extract ACR for Stream 0
(643 rows affected)
Consolidate data for Stream 0
===> END Tue Jan 12 15:09:52 EAT 2010
However when executed via cron, it only outputs:
===> START Tue Jan 12 15:14:00 EAT 2010
Date From:
Date To:
Processing DM ACR
Interactive mode off.
===> END Tue Jan 12 15:14:01 EAT 2010
I dont know why this is happening when the scripts is executed via cron.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2010 01:16 AM
01-12-2010 01:16 AM
Re: Script Execution Unable to Log When Executed Via Cron
what are your crontab entries for the same job , can you please tell.
try redirecting the O/P as well as errors to some file and check.
also you can check actual result that this should perform sa run as a cron job for the same.
regards
sujit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2010 01:17 AM
01-12-2010 01:17 AM
Re: Script Execution Unable to Log When Executed Via Cron
PATH=/usr/sbin:/usr/bin:/whatever....
(You can copy this variable from the one that your system is using - see profile for root)
Best regards,
Horia.
Horia.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2010 01:24 AM
01-12-2010 01:24 AM
Re: Script Execution Unable to Log When Executed Via Cron
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2010 01:41 AM
01-12-2010 01:41 AM
Re: Script Execution Unable to Log When Executed Via Cron
>>PATH is already defined in the user's .profile ..<<
Please notice that no login is performed when a cron job is executed, hence the user's .profile is not read.
You should define your variables or the full command paths in your script.
regards,
John K.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2010 01:45 AM
01-12-2010 01:45 AM
Re: Script Execution Unable to Log When Executed Via Cron
Horia.
Horia.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2010 03:05 AM
01-12-2010 03:05 AM
Re: Script Execution Unable to Log When Executed Via Cron
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2010 03:06 AM
01-12-2010 03:06 AM
Re: Script Execution Unable to Log When Executed Via Cron
Horia.
Horia.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2010 03:43 AM
01-12-2010 03:43 AM
Re: Script Execution Unable to Log When Executed Via Cron
Adding "set -x" to the start of your script will log commands as executed. Then look need the end for the error.
I assume you aren't trying to use any aliases you have defined in your .profile?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2010 03:44 AM
01-12-2010 03:44 AM
Re: Script Execution Unable to Log When Executed Via Cron
Why would you want to do that? The crontab entry is already being processed asynchronously and you should let it wait until done.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2010 04:47 AM
01-12-2010 04:47 AM
Re: Script Execution Unable to Log When Executed Via Cron
check also the mail of the script-executing user: if you have not redirected output from cron execution to a file, it will appear there.
regards,
John K.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2010 06:22 AM
01-13-2010 06:22 AM
Re: Script Execution Unable to Log When Executed Via Cron
command 2>&1 1>/path/to/logfile
may help. Edit your script.
Unix operates with beer.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2010 06:49 PM
01-13-2010 06:49 PM
Re: Script Execution Unable to Log When Executed Via Cron
what actually the script does it is selecting data from a table, and then drops it.
If the script is ran manually, an output of affected rows is logged. The output looks like this:
(1 row affected)
Create table tempdb..XXX_ACR
(0 rows affected)
Extract ACR for Stream 0
(644 rows affected)
Consolidate data for Stream 0
(644 rows affected)
DROP TABLE for tempdb..XXX_ACR_0
Extract ACR for Stream 1
(608 rows affected)
Using cron, the above output is not logged when the script executes.
I don't know why I can't successfully log everything to my logfile when the script runs using cron. What's with cron and manually executing the script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2010 08:20 PM
01-13-2010 08:20 PM
Re: Script Execution Unable to Log When Executed Via Cron
> executing the script?
Who can see "the script"? You and the
psychics? I'm neither.
> Adding "set -x" [...]
Did you try that?
> command 2>&1 1>/path/to/logfile
Did you try that?
Did you try anything which might give us some
useful information?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2010 08:40 PM
01-13-2010 08:40 PM
Re: Script Execution Unable to Log When Executed Via Cron
Have you removed that "&"? cron may "hangup" the process tree when the initial shell exits because it isn't waiting for your script.
How long does the script take to run? Use time in both cases:
time /dir/script.sh
(This will send cron mail so remove when done.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-14-2010 03:59 AM
01-14-2010 03:59 AM
Re: Script Execution Unable to Log When Executed Via Cron
No, it's not about errors. The standard error is a 'separate channel' to output messages to, and some applications like rsync output messages also to stderr even if they are succesfully finished. Please try that method I suggested and report back if it helped.
# command 2>&1 1>/path/to/logfile
Unix operates with beer.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-15-2010 03:40 AM
01-15-2010 03:40 AM
Re: Script Execution Unable to Log When Executed Via Cron
Did you really want to redirect FD in this order? This will send stderr to the previous stdout, then the new stdout is going to logfile.
Typically if you want both to the same file:
... > /path/to/logfile 2>&1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-15-2010 05:16 AM
01-15-2010 05:16 AM
Re: Script Execution Unable to Log When Executed Via Cron
# command 1>/path/to/logfile 2>&1
Unix operates with beer.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2010 04:49 AM
01-21-2010 04:49 AM
Re: Script Execution Unable to Log When Executed Via Cron
I was able to solve the problem already.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2010 08:25 AM
01-21-2010 08:25 AM
Re: Script Execution Unable to Log When Executed Via Cron
How? Let us know, maybe we can also learn something new!
Unix operates with beer.