LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Puppy (https://www.linuxquestions.org/questions/puppy-71/)
-   -   Pid in bash script filename? (https://www.linuxquestions.org/questions/puppy-71/pid-in-bash-script-filename-4175605231/)

Uxhamby 05-04-2017 05:55 AM

Pid in bash script filename?
 
How can i have a bash script use its pid number as part of a file name?

Thanks.

Brian H

pan64 05-04-2017 05:57 AM

can you please give us more details/some example?

michaelk 05-04-2017 06:16 AM

A PID is assigned when the process is created i.e. when your script is executed and will not be the same if you run it again. Most services create a pid file which is deleted when it is stopped by the init system.

So can you explain why you want to use the PID as part of the file name? You can find its pid using the pidof command.

smallpond 05-04-2017 06:19 AM

The pid is $$ so you can create a filename as

Code:

FIL=$$.txt

Uxhamby 05-04-2017 06:28 PM

thanks SmallPond
 
Thanks SmallPond, that is exactly what I needed.

Cheers,

Brian H.

hydrurga 05-04-2017 06:46 PM

Glad you solved your problem, Uxhamby. :)

Could you please mark the thread as "Solved" (see "Thread Tools" at the top of the thread). Cheers.


All times are GMT -5. The time now is 04:10 AM.