Process id's in file names


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Process id's in file names
# 1  
Old 03-07-2008
Process id's in file names

Hello,

I am editing a script which has a .sh extension but is listed as #! /bin/ksh that has output files where process ID's are somehow getting tacked onto the end of the filename. The programmer codes these scripts as "/tmp/email_file$$" saying that he put the $$ in there to be able to handle the process ID that unix seems to want to give it. I have never see this or had problems with this in the past in my other job - is there a way to output these files so that the process ID isn't produced at the end of the file? Or do I have to put $$ at the end to accomodate it?

Thanks,
# 2  
Old 03-07-2008
What the original code was trying to do - create unique filenames using a poor man's shell script method. It's a common thing to do when the job ran yesterday or runs concurrently with the same filenames, and there is a chance that your script could minsterpret the presence of those files to mean something bad. Like not send email when it was supposed to.

If it offends you, use the mv command at the end of the script:
Code:
mv /tmp/email_file$$ /tmp/email_file

to clean up.

Be aware of concurrency issues before you do this.

You can also have the script cleanup (assuming it always runs under the same username)
after itself, so you don't have to.

Code:
find /tmp -name 'email_file*' -mtime +3 -exec rm -f {} \;

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Monitoring processes in parallel and process log file after process exits

I am writing a script to kick off a process to gather logs on multiple nodes in parallel using "&". These processes create individual log files. Which I would like to filter and convert in CSV format after they are complete. I am facing following issues: 1. Monitor all Processes parallelly.... (5 Replies)
Discussion started by: shunya
5 Replies

2. Shell Programming and Scripting

Exclude certain file names while selectingData files coming in different names in a file name called

Data files coming in different names in a file name called process.txt. 1. shipments_yyyymmdd.gz 2 Order_yyyymmdd.gz 3. Invoice_yyyymmdd.gz 4. globalorder_yyyymmdd.gz The process needs to discard all the below files and only process two of the 4 file names available ... (1 Reply)
Discussion started by: dsravanam
1 Replies

3. Shell Programming and Scripting

Checking Multiple File existance in a UNIX folder(Note: File names are all different)

HI Guys, I have some 8 files with different name and extensions. I need to check if they are present in a specific folder or not and also want that script to show me which all are not present. I can write if condition for each file but from a developer perspective , i feel that is not a good... (3 Replies)
Discussion started by: shankarpanda003
3 Replies

4. Shell Programming and Scripting

Change the file name and copy old file content to new file names.

Hi, I have a files in a directory as below :- ls -1 mqdepth-S1STC02 proc-mq-S1STC01 proc-mq-S1STC02 proc-mq-S1STC03 Whereever i have S1STC i need to copy them into new file with file name S2STC. expected output :- ls -1 mqdepth-S2STC02 proc-mq-S2STC01 proc-mq-S2STC02... (3 Replies)
Discussion started by: satishmallidi
3 Replies

5. Shell Programming and Scripting

Split File by Pattern with File Names in Source File... Awk?

Hi all, I'm pretty new to Shell scripting and I need some help to split a source text file into multiple files. The source has a row with pattern where the file needs to be split, and the pattern row also contains the file name of the destination for that specific piece. Here is an example: ... (2 Replies)
Discussion started by: cul8er
2 Replies

6. Programming

Serching process names

#include <stdio.h> #include <string.h> int main(void) { char buf; int transcount=0, elapsetotal=0; while(!feof(stdin)) { int newoluf=0, elapsetime=-1; char timestamp={0}; buf='\0'; // Blank out... (2 Replies)
Discussion started by: sena
2 Replies

7. Shell Programming and Scripting

Searching for file names in a directory while ignoring certain file names

Sun Solaris Unix Question Haven't been able to find any solution for this situation. Let's just say the file names listed below exist in a directory. I want the find command to find all files in this directory but at the same time I want to eliminate certain file names or files with certain... (2 Replies)
Discussion started by: 2reperry
2 Replies

8. Shell Programming and Scripting

eleminate repated process names and get second column value

i want shell script who can eliminate those repeated process and get value of top process of second column. Mark with red one only i want other repeated process should be eliminate but how? Help me out guys. oracle 496094 oracle 471572 oracle 471497 oracle 470561 ko9coll 96157... (4 Replies)
Discussion started by: siddiqui
4 Replies

9. Shell Programming and Scripting

Reading file names from a file and executing the relative file from shell script

Hi How can i dynamically read files names from a list file and execute them from a single shell script. Please help its urgent Thanks in Advance (4 Replies)
Discussion started by: anushilrai
4 Replies

10. UNIX for Dummies Questions & Answers

Displaying VERY long process names with ps -ef

Hi, I'm trying to display all process on an AIX server with the string SLRServer in them. Normally "ps -ef|grep SLRServer" would be sufficient, however in this instance the process name is enormous and the part which contains this string has been truncated, as you can see in the example below ... (8 Replies)
Discussion started by: m223464
8 Replies
Login or Register to Ask a Question