Sponsored Content
Top Forums UNIX for Advanced & Expert Users Last touched file by a specific program ? Post 302926319 by derekludwig on Sunday 23rd of November 2014 09:35:55 AM
Old 11-23-2014
With respect to RudiC, use of a file's access time can be problematic if any other process reads the file, such as backups.

Why 3 programs? Are they three instances of the same program?

If the expense of starting a new process is not onerous, perhaps it would be easier just to use a dispatcher that launches no more than N of your programs:

(pseudo shell code!)
Code:
filescanner | while read file; do
  while [[ ${N} -le $(pgrep appropriateoptions | wc -l) ]]; sleep ${time}; done
  fileomatic ${file} &
done

Or the dispatcher could write a file to one of N named-pipes, one for each fileomatic, something like:

(more pseudo shell code)
Code:
work=$(mktemp -d)

N=0

while read fileomatic; do
  (( N = N + 1 ))
  pipe=${work}/pipe.${N}
  ready=${work}/ready.${N}

  mkfifo ${pipe}

  ${fileomatic} ${ready} < ${pipe} &
done 

filescanner | while read file; do

  while sleep ${delay}; do

    ls -1 ${work}/*.ready | read -aready

    if [[ 0 -lt ${#ready[*]} ]]; then
      i=$(( ${RANDOM} % ${#ready[*]} ))
      n=${ready[$i]}
      echo "${file}" >> ${work}/pipe.${n##*.}
      break
    fi

  done

done

The idea is that the fileomatic will touch the 'ready' file when it can process a file

Last edited by derekludwig; 11-27-2014 at 02:59 PM.. Reason: Typo in arithmantic expression, and some bad logic
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Which Base Level Filesets needed by a specific program?

hello... thats a great forum btw :) my problem is that I need a list of the Base Level Filesets (BLF) which are needed by a specific program. Is there any command/tool which shows me that? during the installation I can choose "Preview only" so that I can see what BLF´s are missing etc but... (4 Replies)
Discussion started by: cypher82
4 Replies

2. UNIX for Dummies Questions & Answers

comparing timestamp of a file with its touched version

Hi, I'm new to unix,I wanna know how can I compare timestamp of a file with its touched version.i.e I want to be sure if the touch command has worked properly i.e if the file has been touched then a msg should be printed saying success else failure.All this to be incurred in a script. Any... (2 Replies)
Discussion started by: prince258
2 Replies

3. UNIX for Advanced & Expert Users

Checking mem usage at specific times in a program

Hi all, I'm running a simulator and I'm noticing an slow increase in memory for long simulations such that the simulation has to end because of a lack of memory. A colleague of mine ran Valgrind memcheck and reported that nothing of interest was reported other than known mem leaks. My advisor... (2 Replies)
Discussion started by: pl4u
2 Replies

4. What is on Your Mind?

Finally I touched 1000.Yahooooo!!!

This, my venerable audience, is my 1000th post here. Thanks for your support and help..:b: ---Vidyadhar:) (4 Replies)
Discussion started by: vidyadhar85
4 Replies

5. UNIX for Dummies Questions & Answers

Never touched UNIX before.. Where do I start?

I will be taking a UNIX course as a part of my college Data Com concentration curriculum. Just thought it would be a good idea to get a little head start, since this class will most likely be quite difficult for someone like me. I never did any programming and I never dealt with Unix or Linux short... (3 Replies)
Discussion started by: ibex333
3 Replies

6. AIX

how to find which program that update a specific file

Hello Would you tell me how to find which program that update a specific file? I am implementing migration project. My machines OS are AIX. It is because lack of documentation, some program cannot working properly on new machine. We found the root cause of this problem is that some data... (4 Replies)
Discussion started by: cstsang
4 Replies

7. Shell Programming and Scripting

Extract specific line in an html file starting and ending with specific pattern to a text file

Hi This is my first post and I'm just a beginner. So please be nice to me. I have a couple of html files where a pattern beginning with "http://www.site.com" and ending with "/resource.dat" is present on every 241st line. How do I extract this to a new text file? I have tried sed -n 241,241p... (13 Replies)
Discussion started by: dejavo
13 Replies

8. Shell Programming and Scripting

Program to search for the files with specific format

Hi All, Your help on the below requirement is highly appreciated. I am building a program which should pick the file from a source directory and place them into target directory. While selecting the file in source it should look for some pattern in the file name. Ex: File Name 1:... (10 Replies)
Discussion started by: bharath561989
10 Replies

9. Shell Programming and Scripting

Running program and output files in specific directories

I have been running a program mseed2sac using the following command cd IV find . -type f -exec /swadmin/mseed2sac '{}' \; The problem is that I end up with a lot of files in directory IV. Instead I would like to select the designator HHZ, create a directory IV.SAC and all the files output... (11 Replies)
Discussion started by: kristinu
11 Replies

10. UNIX for Beginners Questions & Answers

Seraching for a specific program

I know that Qt exists on this IMX6+ the device has Linux 4.9.184 embedded. I need to figure out which version of Qt it has. What is the best way to find a program given only a text based terminal? Is there a way I can grep for it? (2 Replies)
Discussion started by: Circuits
2 Replies
MH-DRAFT(5)							     [nmh-1.5]							       MH-DRAFT(5)

NAME
mh-draft - draft folder facility for nmh message system SYNOPSIS
any nmh command DESCRIPTION
There are a number of interesting advanced facilities for the composition of outgoing mail. The Draft Folder The comp, dist, forw, repl, and whom commands have two additional switches, -draftfolder +folder and -draftmessage msg which allow you to manipulate the various draft messages you are composing. If -draftfolder +folder is used, these commands are directed to construct a draft message in the indicated folder. (The "Draft-Folder" profile entry may be used to declare a default draft folder for use with comp, dist, forw, repl, and whom ). If the swith -draftmessage msg is given, the specified draft is used to compose the message. If -draftmessage msg is not used, then the draft defaults to `new' (create a new draft) unless the user invokes comp with -use, in which case the default is `cur'. Hence, the user may have several message compositions in progress simultaneously. Now, all of the nmh tools are available on each of the user's message drafts (e.g. show, scan, pick, and so on). If the folder does not exist, the user is asked if it should be created (just like with refile). Also, the last draft message the user was composing is known as `cur' in the draft folder. Furthermore, the send command has these switches as well. Hence, from the shell, the user can send off whatever drafts desired using the standard nmh `msgs' convention with -draftmessage msgs. If no `msgs' are given, it defaults to `cur'. In addition, all five programs have a -nodraftfolder switch, which undoes the last occurrence of -draftfolder folder (useful if the latter occurs in the user's nmh profile). If the user does not give the -draftfolder +folder switch, then all these commands act "normally". Note that the -draft switch to send and show still refers to the file called `draft' in the user's nmh directory. In the interests of economy of expression, when using comp or send, the user needn't prefix the draft `msg' or `msgs' with -draftmessage. Both of these commands accept a `file' or `files' argument, and they will, if given -draftfolder +folder treat these arguments as `msg' or `msgs'. (This may appear to be inconsistent, at first, but it saves a lot of typing) Hence, send -draftfolder +drafts first is the same as send -draftfolder +drafts -draftmessage first To make all this a bit more clear, here are some examples. Let's assume that the following entries are in the nmh profile: Draft-Folder: +drafts sendf: -draftfolder +drafts Furthermore, let's assume that the program sendf is a (symbolic) link in the user's $HOME/bin/ directory to send. Then, any of the com- mands comp dist forw repl constructs the message draft in the `draft' folder using the `new' message number. Furthermore, they each define `cur' in this folder to be that message draft. If the user were to use the quit option at `What now?' level, then later on, if no other draft composition was done, the draft could be sent with simply sendf Or, if more editing was required, the draft could be edited with comp -use Instead, if other drafts had been composed in the meantime, so that this message draft was no longer known as `cur' in the `draft' folder, then the user could scan the folder to see which message draft in the folder should be used for editing or sending. Clever users could even employ a back-quoted pick to do the work: comp -use `pick +drafts -to nmh-workers` or sendf `pick +drafts -to nmh-workers` Note that in the comp example, the output from pick must resolve to a single message draft (it makes no sense to talk about composing two or more drafts with one invocation of comp). In contrast, in the send example, as many message drafts as desired can appear, since send doesn't mind sending more than one draft at a time. Note that the argument -draftfolder +folder is not included in the profile entry for send, since when comp, et. al., invoke send directly, they supply send with the UNIX pathname of the message draft, and not a -draftmessage msg argument. As far as send is concerned, a draft folder is not being used. It is important to realize that nmh treats the draft folder like a standard nmh folder in nearly all respects. There are two exceptions: First, under no circumstancs will the -draftfolder folder switch cause the named folder to become the current folder. Obviously, if the folder appeared in the context of a standard +folder argument to an nmh program, as in scan +drafts it might become the current folder, depending on the context changes of the nmh program in question. Second, although conceptually send deletes the `msgs' named in the draft folder, it does not call delete-prog to perform the deletion. What Happens if the Draft Exists When the comp, dist, forw, and repl commands are invoked and the draft you indicated already exists, these programs will prompt the user for a reponse directing the program's action. The prompt is Draft ``/home/foobar/nmhbox/draft'' exists (xx bytes). Disposition? The appropriate responses and their meanings are: replace - deletes the draft and starts afresh list - lists the draft refile - files the draft into a folder and starts afresh quit - leaves the draft intact and exits In addition, if you specified -draftfolder folder to the command, then one other response will be accepted: new - finds a new draft just as if -draftmessage new had been given. Finally, the comp command will accept one more response: use - re-uses the draft just as if -use had been given. CONTEXT
None MH.6.8 11 June 2012 MH-DRAFT(5)
All times are GMT -4. The time now is 07:42 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy