- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Using the nohup command !
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-28-2006 12:38 PM
06-28-2006 12:38 PM
Using the nohup command !
I have a strange behavior with a script that has defined the nohup command in his content.
The problem is when i execute this script through the crontab scheduler, because this doesn't leaves running the executable program. But if I execute this script since the unix prompt the script run succesfully.
NOTE: The name of the executable program is Interprete.
The line of the nohup command is
nohup Interprete &
The porpuose of this script is when a backup process finished, the crontab scheduler launch this script leaving the Interprete program running on the system like a daemon.
In other times when i execute the nohup line since the crontab scheduler, the nohup.out file doesn´t increase his size like the Interprete program doesn´t works.
30 23 * * * /usr/bin/nohup /switch/Interprete & > /switch/nohup.out
The nohup.out is used like a log file for the behavior of the Interprete program.
Some idea ?
- Tags:
- nohup
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2006 01:26 PM
06-28-2006 01:26 PM
Re: Using the nohup command !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2006 03:48 PM
06-28-2006 03:48 PM
Re: Using the nohup command !
The attached Perl script will do the job for you and because it fork()'s and exec()'s there is no need to start it in the background --- another characteristic of a proper daemon.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2006 03:48 PM
06-28-2006 03:48 PM
Re: Using the nohup command !
The attached Perl script will do the job for you and because it fork()'s and exec()'s there is no need to start it in the background --- another characteristic of a proper daemon.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2006 03:58 PM
06-28-2006 03:58 PM
Re: Using the nohup command !
want to daemonize another process then change the line in daemon.pl that contains the exec() function. I could have made a fancier version that actually parsed the command line for the command to exec but I already have a script that was close --- and besides, the fancy additions such as passing the command and it's arguments and any possibly needed environment variables needed by the exec()'ed command is left as an exercise.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2006 04:27 PM
06-28-2006 04:27 PM
Re: Using the nohup command !
If you want to run through cron , then no need to go for nohup , just remove that and try it , hope it will work fine,
Cheers,
Raj.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2006 07:51 PM
06-28-2006 07:51 PM
Re: Using the nohup command !
I agree with Raj to some extent.
See the basic purpose of nohup is to allow the process to run and ignore hangups and exits [ which are the signals sents while logging out to all the processes started from your login, if you have logged in and run a command/process ]
When you are scheduling a command/process to run via cron - you are not logging in and logging out, and hence the source of exit and hangup signals is already avoided and hence you need not use nohup through cron. BUT any later exit or hangup signals to the process will not be ignored as you have not used nohup. This may be done by using trap in your script to ignore the hangup and exit signals.
But I feel the most elegant and authentic method if you want to really call it as a daemon would be to follow Clay's advise.
Regards,
Ninad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2006 04:20 PM
06-29-2006 04:20 PM
Re: Using the nohup command !
nohup /switch/interprete 2>&1 1>/switch/nohup.out &
next run:
tail -f /switch/nohup.out
beak out anything here using tail..
---
next create a parent caller, say do_cron program. In this program it will have one line as above...
30 23 * * * /switch/do_cron
the do_cron will have one line of:
nohup /switch/interpret 2>&1 1>/switch/nohup.out &
I think the parent caller named do_cron will be able to exit via cron with no problem.
If you want, add a second line to do_cron, the last line will be say example:
exit 5
next verify the ReturnCode (rc=) for the cron job #### number.. by looking at the "cron.log"... it might be in /usr/spool/cron directory. do a man cron if you need some help to find the "cron.log" file.. might be at the end of the 'man cron" output.. see the line named "SEE FILES" in the doc.
best regards,
Tom
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-30-2006 11:32 AM
06-30-2006 11:32 AM
Re: Using the nohup command !
But when i invoke the script in the cron scheduler the Interprete program runs fine , but the nohup.out file doesn't registry anything.
More ideas ??
Best Regards!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-30-2006 02:06 PM
06-30-2006 02:06 PM
Re: Using the nohup command !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2006 12:19 AM
07-03-2006 12:19 AM
Re: Using the nohup command !
Thanks to Clay for the comments on this thread. It pointed me in the right direction and solved the problem.
You should take Clay's advice.
-denver
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2006 03:42 AM
07-03-2006 03:42 AM
Re: Using the nohup command !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2006 05:11 AM
07-03-2006 05:11 AM
Re: Using the nohup command !
I have the "perl D.5.8.3.B" installed on the server. If i want to scheduler the perl program, is enough to invoke the program by his name since the cron schedule?.
Sorry but i don´t have experience with perl.
Thank's for your time an advices!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2006 05:26 AM
07-03-2006 05:26 AM
Re: Using the nohup command !
Your wrapper script might look something like this:
#!/usr/bin/sh
typeset LOGFILE=/var/tmp/myfile${$}.log
typeset ERRFILE=/var/tmp/myfile${$}.err
export PATH=${PATH}:/usr/bin:/usr/local/bin:/opt/perl/bin
export MYVAR=dumbo
export MYVAR2="Mickey Mouse"
typeset -i STAT=0
perl mydaemon.pl > ${LOGFILE} 2>${ERRFILE}
STAT=${?}
exit ${STAT}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2006 06:16 AM
07-03-2006 06:16 AM
Re: Using the nohup command !
In fact the Interprete program is an executable C program, that runs like a daemon (maybe is not a good comparison), but this program it must stay running for catching all the incoming transferences, and those transference keep and entry in the nohup.out file.
I don't known if is the best solution for this task, but actually that´s is the form that they work.
Best Regards !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2006 07:20 AM
07-03-2006 07:20 AM
Re: Using the nohup command !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2006 07:22 AM
07-03-2006 07:22 AM