My script stops after logoff...why??


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting My script stops after logoff...why??
# 1  
Old 01-13-2013
My script stops after logoff...why??

Hi'

i am runing a script thats run with a loop...while loop true.

when i exit the server..logon and again the script doenst run.

its a bash script test.sh.

i run it as:

Code:
#./test.sh &

what can be the priblem please?

thanks alot

Last edited by Scrutinizer; 01-13-2013 at 06:24 AM.. Reason: code tags
# 2  
Old 01-13-2013
See
Code:
man nohup

This User Gave Thanks to Scrutinizer For This Post:
# 3  
Old 01-13-2013
ok and what about disown?

or disown -a? what does it mean?
# 4  
Old 01-13-2013
Use disown if you forgot to start job with nohup. The -a option means all jobs that you have started.

Note disown is not available in all shells.
This User Gave Thanks to fpmurphy For This Post:
# 5  
Old 01-14-2013
if this is my code,where should i put the nohup?
Code:
#! /bin/bash
while true
do
   proc_num=$(ps a | grep yourscript | wc -l)
   echo "loop1: "proc_num=$proc_num
   sleep 2
   while (( $proc_num < 5 ))
      do
         echo "loop 2: "proc_num=$proc_num
         sleep 2
         yourscript &      #add a single process
      done
   echo " out of loop 1 "
   sleep 1
done
#let something else use the box done


Last edited by Scrutinizer; 01-14-2013 at 03:07 AM.. Reason: code tags
# 6  
Old 01-14-2013
Try calling the script itself with nohup:
Code:
nohup ./test.sh &

Please use code tags
This User Gave Thanks to Scrutinizer For This Post:
# 7  
Old 01-14-2013
Great!! 10x alot
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Copy Script Stops

Good Morning, I have a copy script on Solaris 9 machine that is supposed to copy some files to a NAS using: cp -r /dir/dir/ /dir/dir/dirThe script doesn't finish. The directory contains user files of which one seems to copy fine, a second was failing until I did achmod -R -777 to it. Now,... (6 Replies)
Discussion started by: Stellaman1977
6 Replies

2. Shell Programming and Scripting

My script stops working when using crontab

I have made a shell script(/bin/sh) that starts a perl script (that I haven't made my self) that's starts a ssh session. The ssh session uses a private/public key to login so no password is needed. The Perl script works perfect. But when I put it in a cronjob (crontab) the ssh connection asks... (6 Replies)
Discussion started by: splinter_cell
6 Replies

3. Shell Programming and Scripting

Case Statement for Login/Logoff Script

I'm currently trying to write a login script. I have already written a logoff script that uses an if/else statement. #!/bin/bash TIMED=$(date +%H) if ' then echo Have a Great Day $USER else echo Have a Great Night $USER fi But I'd like to write one that give me the option of... (1 Reply)
Discussion started by: bbowers
1 Replies

4. Shell Programming and Scripting

Script stops working after copying it

Hi all, When I cp a script, this section of the code stops reading from a file. if ; then while read dirtoclean do DIRSTOCLEAN=${DIRSTOCLEAN}' '$dirtoclean done < ${BASEDIR}test.conf fi ${DIRSTOCLEAN} doesn't return anything, even though it will work right before... (6 Replies)
Discussion started by: nicksantos1
6 Replies

5. Shell Programming and Scripting

Script with infinite loop stops after sometime

Hi I am working on a server that is set up and maintained by a third party. It seems whenever I run bash scripts in the background (with a &) with while loops in them they seem to me killed in around 2.5 hours. ( I am running them as a normal user with no special privileges ) . Is there a... (3 Replies)
Discussion started by: pkabali
3 Replies

6. Shell Programming and Scripting

Logon/Logoff script

I need help for writing a logon/logoff script for recording user's computer usage time. This is for local login only, not for ssh or something like that. When a user logon, there should be a temp file (/home/acct/login_temp) generated including the logname and logon time information in the... (8 Replies)
Discussion started by: jimx
8 Replies

7. Shell Programming and Scripting

cleartool - script stops after using setview

Hi Guys, See the below code. The command below the cleartool setview ITG_Automation is not executing. Could you please suggest. #!/bin/ksh echo $0 cleartool setview ITG_Automation echo $0 (3 Replies)
Discussion started by: ajincoep
3 Replies

8. Shell Programming and Scripting

Why My Script Stops After 1st Command

My script is very simple. It call isql and then echo a message. The problem is after the 1st command (isql), it stops so that the echo line never gets executed. Can anyone let me know what is wrong? #!/usr/bin/sh userid=xxxx server=xxxx db=xxxx pwd=xxxx isql -U ${userid} -S ${server}... (3 Replies)
Discussion started by: robbyls
3 Replies

9. UNIX for Advanced & Expert Users

Running a script during logoff

I know we can put whatever we need to run during login inside /etc/profile or .profile file. I want to run a set of commands before logoff. Where should I put my commands/scripts? Is such facility available? (3 Replies)
Discussion started by: praveenkumar_l
3 Replies

10. UNIX for Dummies Questions & Answers

logoff idle user script

Will someone please share a script with me that will read in each line of the who -u output and if idle time is more than 50 min, execute a kill on the PID? This is what I have so far: who -u | cut -c 40-56 I am comfortable in the korn shell, but I can broaden my horizons if you've got... (4 Replies)
Discussion started by: michieka
4 Replies
Login or Register to Ask a Question