Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

shell scripting and pid control

Status
Not open for further replies.

Jackled

Technical User
May 1, 2003
3
BE
I am trying to develop a simple way to get the pid of a process once it is started. If you start a process in background with the "&", you then get its pid in stdout. But if I run this in a script, let's say a script called "test":
Code:
#!/bin/bash
sleep 60 & > test.log 2>&1
When I run this script, I would expect to get in the file test.log the same information as I get in stdout when I just run "sleep 60 &", which includes the pid.
Well, unfortunately the test.log is desperately empty, even if it is created.
Can someone tell me why?? Or any solution to automatically get the pid of a process, once it is started in a script? (I am not talking about manually doing "ps -ef" and grep, etc, etc, I am looking for something straight and simple.)

 
Sorry chaps, this should have been in the general Unix forum, and I found the answer there in the archives...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top