- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- nohup in crontab
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
06-17-2007 07:51 PM
06-17-2007 07:51 PM
I am trying to run the below script in crontab after every 10 min...
#cat /tmp/xyzchk.sh
CC=`ls /abc/sd/r/spool/Interfaces/BATCH-UPLOADS-5|wc -l`
if [ "$CC" -ne "0" ]
then
echo "File has arrived"
/usr/bin/nohup /xyz/r/cat/script > $out/tfdrtrig.log &
else
echo "File doesnt exist"
fi
What i am doing is checking whether specific file has come and if yes then run a script in background by using nohup..
But when i am checking after file arrives,the cronjob does not run, it does not show in
ps -ef|grep script
Cronjob entry for that user test is as follows:
10,20,30,40,50,59 * * * * /tmp/xyzchk.sh > /dev/null 2>&1..the user test is already mentioned in /var/adm/cron.allow file..
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2007 08:07 PM
06-17-2007 08:07 PM
Re: nohup in crontab
what does /var/adm/cron/log say (if anything?)
HTH
Duncan
I am an HPE Employee

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2007 08:18 PM
06-17-2007 08:18 PM
Re: nohup in crontab
you need to define $out
Check also the mail for the user in question and include the shell interpreter at the beginning. e.g.
#!/usr/bin/sh
regards,
John K.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2007 08:43 PM
06-17-2007 08:43 PM
Re: nohup in crontab
at first do not redirect stdout/stderr to /dev/null but a file or let mail do this work.
So you can inspect your own and system generated messages.
mfG Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2007 09:36 PM
06-17-2007 09:36 PM
Re: nohup in crontab
Thanx for ur response,
i just found a similar topic and i m following raj's advice of running the script without nohup..
But now i would like to know how to
use trap in my script to ignore the hangup and exit signals.
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1038827
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2007 12:53 AM
06-18-2007 12:53 AM
Re: nohup in crontab
A cron job isn't normally going to get a hangup signal. I'm not sure what you mean by exit?
There is a trap on exit from functions, see ksh(1)/sh(1) trap command.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2007 06:55 PM
06-18-2007 06:55 PM
Re: nohup in crontab
Now i am not able to run the script from cronjob without nohup...
After the file ahs arrived, the cron is not getting executed from that particular user which i have mentioned in /var/adm/cron.allow.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2007 08:10 PM
06-18-2007 08:10 PM
Re: nohup in crontab
So what works? What is your current status?
You were asked for the contents of /var/adm/cron/log.
(I assume you meant /var/adm/cron/cron.allow?)
You do know that this will send junk to stderr if it doesn't exist?
CC=`ls .../BATCH-UPLOADS-5|wc -l`
You can fix it by:
ls .../BATCH-UPLOADS-5 > /dev/null 2>&1
if [ $? -eq 0 ]; then
echo "File has arrived"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2007 09:13 PM
06-18-2007 09:13 PM
Re: nohup in crontab
First of all let me make it clear to you as what i want to do ..
i want to run a script called xyz.sh kept in /abc/def/xyz.sh location ,only when a file arrives at /wer/thy/def location.
So im checking for /wer/thy/def locn,by taking word count if its not equal to zero that means the file has arrived and hence i m running the script called xyz.sh from /abc/def/xyz.sh .
this is a scriptm mentioned in my crontab called tfcheck.sh.
#tfcheck.sh
CC=`ls /wer/thy/def |wc -l`
if [ "$CC" -ne "0" ]
then
/abc/def/xyz.sh > $sysout/tfdrtrig.log
else
echo "File doesnot exist"
fi
MY CRONTAB entry is as follows:->
5,10,15,20,25,30,35,40,45,50,55,59 * * * * /tmp/tfcheck.sh > /dev/null 2>&1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2007 09:14 PM
06-18-2007 09:14 PM
Re: nohup in crontab
First of all let me make it clear to you as what i want to do ..
i want to run a script called xyz.sh kept in /abc/def/xyz.sh location ,only when a file arrives at /wer/thy/def location.
So im checking for /wer/thy/def locn,by taking word count if its not equal to zero that means the file has arrived and hence i m running the script called xyz.sh from /abc/def/xyz.sh .
this is a scriptm mentioned in my crontab called tfcheck.sh.
#tfcheck.sh
CC=`ls /wer/thy/def |wc -l`
if [ "$CC" -ne "0" ]
then
/abc/def/xyz.sh > $out/tf.log
else
echo "File doesnot exist"
fi
MY CRONTAB entry is as follows:->
5,10,15,20,25,30,35,40,45,50,55,59 * * * * /tmp/tfcheck.sh > /dev/null 2>&1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2007 09:41 PM
06-18-2007 09:41 PM
Re: nohup in crontab
if your script is located in
/abc/def/xyz.sh
you better put that in your crontab entry instead of
/tmp/tfcheck.sh
regards,
John K.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2007 09:47 PM
06-18-2007 09:47 PM
Re: nohup in crontab
The thing is that abc/def/xyz.sh in turn calls 2-3 scipts more and i can't mofidy that script...
So im using this way to run the script /abc/def/xyz.sh through cron .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2007 10:14 PM
06-18-2007 10:14 PM
SolutionThe first thing you should do is remove the output redirection in the crontab:
10,20,30,40,50,59 * * * * /tmp/xyzchk.sh
The next thing you need to do is look at /var/adm/cron/log after 10 minutes and provide that result.
As mentioned by John, you need to define $out in: /abc/def/xyz.sh > $out/tf.log
Once you have these, you need to provide the cron log, your mail and tf.log.