- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Script not running in cron
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-05-2006 08:02 AM
01-05-2006 08:02 AM
Script not running in cron
I have a shell script in cron which is not running well. It runs fine when executed from shell.
script -
#! /bin/sh
#
QUEUENAME=dhcpmgt
XACTDIR=/var/opt/nid1/output
ls -1rt $XACTDIR | while read file
do
if `/usr/bin/lp -c -d$QUEUENAME $XACTDIR/$file > /dev/null`
then
rm $XACTDIR/$file
fi
done
-------------------------
cron entry
0,10,16,20,25,30,35,40,50 * * * * /opt/nid1/dhcp-fwd.sh > /dev/null
---------------
/var/adm/cron/log : -
> CMD: /opt/nid1/dhcp-fwd.sh > /dev/null 2>/tmp/err
> root 9866 c Thu Jan 5 15:40:01 EST 2006
> CMD: /opt/nid1/dhcp-fwd.sh > /dev/null 2>/tmp/err
> root 15215 c Thu Jan 5 16:00:00 EST 2006
< root 15215 c Thu Jan 5 16:00:00 EST 2006 ts=9
< sspe 15214 c Thu Jan 5 16:00:12 EST 2006 ts=9
pls help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2006 08:05 AM
01-05-2006 08:05 AM
Re: Script not running in cron
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2006 08:10 AM
01-05-2006 08:10 AM
Re: Script not running in cron
0,10,16,20,25,30,35,40,50 * * * * /opt/nid1/dhcp-fwd.sh > /dev/null
and remove the redcirection
0,10,16,20,25,30,35,40,50 * * * * /opt/nid1/dhcp-fwd.sh.
See it makes any difference .
thx,
bl.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2006 08:10 AM
01-05-2006 08:10 AM
Re: Script not running in cron
0,10,16,20,25,30,35,40,50 * * * * /opt/nid1/dhcp-fwd.sh > /dev/null
to
0,10,16,20,25,30,35,40,50 * * * * /opt/nid1/dhcp-fwd.sh > /tmp/dhcp-fwd.cronlog
then post /tmp/dhcp-fwd.cronlog
Most cases - this is an ENV or PATH issue.
Rgds...Geoff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2006 08:18 AM
01-05-2006 08:18 AM
Re: Script not running in cron
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2006 08:20 AM
01-05-2006 08:20 AM
Re: Script not running in cron
,10,16,20,25,30,35,40,50 * * * * /opt/nid1/dhcp-fwd.sh > /tmp/dhcp-fwd.cronlog 2>&1
Rgds...Geoff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2006 08:22 AM
01-05-2006 08:22 AM
Re: Script not running in cron
/var/adm/cron/log : -
> CMD: /opt/nid1/dhcp-fwd.sh > /dev/null 2>/tmp/err
> root 9866 c Thu Jan 5 15:40:01 EST 2006
> CMD: /opt/nid1/dhcp-fwd.sh > /dev/null 2>/tmp/err
> root 15215 c Thu Jan 5 16:00:00 EST 2006
< root 15215 c Thu Jan 5 16:00:00 EST 2006 ts=9
< sspe 15214 c Thu Jan 5 16:00:12 EST 2006 ts=9
The command ran via cron with PID: 9866. You gave the termination info for PID: 15214 (which appears to have been killed via a kill -9)
Find the termination line in the cron log from the 9866 PID.
I would also redirect stdout and stderr to a file for inspection also.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2006 08:33 AM
01-05-2006 08:33 AM
Re: Script not running in cron
Are there any directories in "var/opt/nid1/output". The cron job is getting a sigkill "ts=9".
You can try exporting the user .profile in the script and see if that helps.
-------------------------------
#/usr/bin/ksh
. /path_to_home_dir/.profile
.....
your script
-------------------------------
Hope this helps.
regds
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2006 09:33 AM
01-05-2006 09:33 AM
Re: Script not running in cron
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2006 08:52 PM
01-05-2006 08:52 PM
Re: Script not running in cron
check mail messages for the cron user; it should give a clue.
regards,
John K.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2006 09:18 PM
01-05-2006 09:18 PM
Re: Script not running in cron
if `/usr/bin/lp -c -d$QUEUENAME $XACTDIR/$file 2> /dev/null`
regards,
John K.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-06-2006 01:27 AM
01-06-2006 01:27 AM
Re: Script not running in cron
The "if" statement could be returning a different code than expected because two results are inspected: the print and the redirect. The redirect is always successfull.
Maybe someone else can explain why this would work differently when issued in a "batch" or "terminal" environment...
Try removing the redirect as suggested earlier. The cron user will have mail to report activity.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-06-2006 01:50 AM
01-06-2006 01:50 AM
Re: Script not running in cron
check the mail for cron and the file for any issues...
Cheerz
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2006 07:43 PM
01-08-2006 07:43 PM
Re: Script not running in cron
load the .profile in script and try again.
remeber that crontab doesn't load the .profile of teh user.
HTH,
Art
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2006 07:54 PM
01-08-2006 07:54 PM
Re: Script not running in cron
#! /bin/sh
#
QUEUENAME=dhcpmgt
XACTDIR=/var/opt/nid1/output
ls -1rt $XACTDIR | while read file
do
/usr/bin/lp -c -d$QUEUENAME $XACTDIR/$file 1> /dev/null 2>&1
if [[ ${?} -eq 0 ]]
then
# Uncomment
# echo "Action Completed" | mail mailID
rm $XACTDIR/$file
fi
done
exit 0
##########
0,10,16,20,25,30,35,40,50 * * * * /opt/nid1/dhcp-fwd.sh 1> /dev/null 2>&1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2006 07:54 PM
01-08-2006 07:54 PM
Re: Script not running in cron
#! /bin/sh
#
QUEUENAME=dhcpmgt
XACTDIR=/var/opt/nid1/output
ls -1rt $XACTDIR | while read file
do
/usr/bin/lp -c -d$QUEUENAME $XACTDIR/$file 1> /dev/null 2>&1
if [[ ${?} -eq 0 ]]
then
# Uncomment
# echo "Action Completed" | mail mailID
rm $XACTDIR/$file
fi
done
exit 0
##########
0,10,16,20,25,30,35,40,50 * * * * /opt/nid1/dhcp-fwd.sh 1> /dev/null 2>&1
--
Muthu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2006 07:54 PM
01-08-2006 07:54 PM
Re: Script not running in cron
change the cron to:
0,10,16,20,25,30,35,40,50 * * * * su - USERNAME -c "/opt/nid1/dhcp-fwd.sh > /dev/null"
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2006 09:08 PM
01-08-2006 09:08 PM
Re: Script not running in cron
regards,
Darren.