![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| nohup.out | ramky79 | AIX | 5 | 10-23-2007 03:28 AM |
| nohup - help! | bluemoon1 | UNIX for Dummies Questions & Answers | 9 | 10-11-2007 08:49 PM |
| Help on nohup | bobbyjohnz | UNIX for Advanced & Expert Users | 3 | 10-18-2006 08:56 AM |
| Nohup | miwinter | UNIX for Dummies Questions & Answers | 3 | 07-21-2006 02:20 AM |
| nohup in cron | abhijeetkul | Shell Programming and Scripting | 6 | 11-19-2005 10:50 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
nohup in cron job
Hello,
I have bunch of shell scripts, which I want to execute every hour in the background. So I created a script mainscript.sh which executes these hourly scripts in the background. Script goes like this. mainscript.sh #!/bin/sh nohup sh subscript1.sh & nohup sh subscrip2.sh & exit 0 And I set up this mainscript.sh script through cron to execute every hour. When I run this script manually it runs all other scripts properly in the background. But nothing is happening with cron setup. Your help is appreciable thanks papachi_2000 |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
What does your cron entry look like?
Why are you using nohup? Nohup is for if you are logged in, and don't want the job to exit when you log out, if you start the job from a terminal. Cron has no terminal associated with it. Therefore, nohup does not help you. -Mike |
|
#3
|
|||
|
|||
|
Hi thr,
try to put ". .profile" at the start of your calling script. I guess "&" does not work in cron. Regards Abhijeet |
|
#4
|
|||
|
|||
|
I used nohup because like mike mentioned I don't want the job to exit when I log out. If Cron has no terminal associated with it, So that means I don’t have to use nohup?
But I want all shell scripts to execute background. If I don’t use '&' would they run in back ground? I don’t want them to wait for other shell to execute. So to achieve my requirement what should I do? And abhijeet I did used '. .profile' still it won’t work. Thanks to all, Papachi |
|
#5
|
|||
|
|||
|
You don't need the nohup, because the script is running without being linked to a terminal session and nohup is needed when you want to end a session and keep a job running.
I could be wrong, but I think you're right to use the Ampersand to allow both subscripts to run concurrently. I think the point Abhijeetkul was making about the .profile was that the environment used by the Cron job (root's?) will be different from your own and it may be that the PATH variable is not the same, so the job as run by the cron may not be able to find your script, or subscripts. You could try logging in as root (or whatever user's cron you're using) and running the script using the same command as entered in the cron to see if it works. cheers |
|
#6
|
|||
|
|||
|
Hello all,
I faced a similar problem recently.Only exception was i need not have "&". All my scripts were working fine when run manually,but not the same in cron. I thought of calling my user's .profile in it & i succeeded. Hope your problem solves out soon. Try . $HOME/.profile Regards Abhijeet |
|||
| Google The UNIX and Linux Forums |