Run a job in background for infinte time


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Run a job in background for infinte time
# 1  
Old 09-29-2006
Run a job in background for infinte time

Hello All,

I would like to know if it is possible to launch a job in background for infinite time.

example:

myScript.ksh
while true
do
( echo "(`date`)"; top -U user | grep 'Memory:' ) >> log &
sleep 1800
done

and when i do myScript.ksh & my log file is just updated for the first time and never again.

but when i do myScript.ksh it works kool.

could someone suggests me pls

tnx
# 2  
Old 09-29-2006
Are you executing in background and then logging out? If so, try:
Code:
nohup myScript.ksh &

Regards.
# 3  
Old 09-29-2006
No, iam leaving my session open.

Infact i just wanted to check the resources at certain time during weekdays.
# 4  
Old 09-29-2006
Well, that's a strange behaviour, then...
Why don't you schedule it in a cron job?
Code:
00,30 * * * * myScript.sh > /dev/null 2>&1

And remove the while loop inside the script, of course Smilie
Regards.
# 5  
Old 09-29-2006
the worst thing is that i am not admin. if i want to do that i have to request the sys admin and its big process flow ( request on homologation + tests + manager approval + request for prod).

i dont want go through the hectic process for this simple pgm.

will try to find another way.

tnx a lot

regards.
# 6  
Old 09-29-2006
I see... Well, try anyway the "nohup" solution, just in case, becasue your script seems to be OK.
Regards.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Cron job - Need to run Cron every quarter at particular time

Hi, 1) If some job supposed to run on 1st of every month at 7 AM In cron job when we have a blackout on the 1st ( i.e when 1st falls on a sunday ) how can we make the job run the next business day? 2) How can we run a job on 25th of every quarter 7 AM(jan,apr,jul,oct) And if 25th... (5 Replies)
Discussion started by: System Admin 77
5 Replies

2. Shell Programming and Scripting

Cron doesn't run job in background

Hi, First of all merry christmas and Happy holidays to all :D My situation is as below, When a backup job runs on a mainframe server, it creates a 0byte file on a network drive which is accessible through linux Linux server : Red Hat Enterprise Linux Server release 5.3 Beta (Tikanga) File... (6 Replies)
Discussion started by: sam05121988
6 Replies

3. Shell Programming and Scripting

Background job issue

How to bring a backgroud job say sample_script.sh to foreground (4 Replies)
Discussion started by: rafa_fed2
4 Replies

4. Shell Programming and Scripting

Background Job

Hello Everyody, Having a doubt. sort file1 & when we sent a job to the background it returns Job Number PID again if we want to ... (1 Reply)
Discussion started by: knroy10
1 Replies

5. UNIX for Dummies Questions & Answers

Run script in the background with a time interval

I have a script I want to run in the background, and I have looked it up but I am not exactly sure how to do. First of all to run it in the background do you have to put something in the script or is it just a command when you go to run it. I found this solution to it but once again I am not to... (2 Replies)
Discussion started by: mauler123
2 Replies

6. Shell Programming and Scripting

Run job for a period of time

I have a job that runs for an unspecified amount of time. I want to run this as a cron job for a specified amount of time, say 2 hours. Once the time is up, the program should be killed in the middle of execution. How can I do this? Thanks. (5 Replies)
Discussion started by: cooldude
5 Replies

7. UNIX for Dummies Questions & Answers

background job

on gnome i open a terminal and run wget http://soommmething & in the background. because wget shows me downloading progress percentage and download speed continuously, I exit the gnome-terminal after a while i want to see the download percentage but dont know how. my ps -u myname shows that... (3 Replies)
Discussion started by: babayeve
3 Replies

8. UNIX for Dummies Questions & Answers

Background job

Hiya, Recently I've run a few scripts in the foreground, but have realised later they should of been better nohup'd and placed in the background. I understand how to change a foreground job into a background one, but how would put the job into the nohup state? Thanks (1 Reply)
Discussion started by: rdbooth
1 Replies

9. UNIX for Dummies Questions & Answers

background job

I try to run a script as background job. script: #!/usr/bin/csh /usr/bin/date +20%y-%m-%d > ~/datsql.txt If I start it I got this output: tac> ./datermitteln& 293 + Stopped (SIGTTOU) ./datermitteln& I insert the following line inside my script, but without any... (3 Replies)
Discussion started by: joerg
3 Replies
Login or Register to Ask a Question