Re: Increment counter upon each execution of shell script
- From: Myx <mariya.nagorna@xxxxxxxxx>
- Date: Mon, 30 Jun 2008 08:47:02 -0700 (PDT)
Thank you all for your help. I will try out the things you recommended
and hope at least one of them does what I need it to do.
The reason for this counter is that the way that the files that I wish
to get from a remote server are named is something like the following:
SYSTEM.LOGFILE.G4401V00. Every day, there's a new file that gets
added, where the G4401 becomes G4402, etc. So I was thinking of
keeping a counter in a separate file that would do this incrementation
and then concatenate the strings to form the entire file name. Please
let me know if you think this approach is a reasonable one and if not,
any suggestions are more than welcome.
Thanks
On Jun 27, 6:16 pm, phil-news-nos...@xxxxxxxx wrote:
On Fri, 27 Jun 2008 03:18:52 +0100 Ben Bacarisse <ben.use...@xxxxxxxxx> wrote:
| You need a file to store the counter, like this:
|
| #!/bin/bash
|
| read COUNT <counter
| echo $COUNT
| echo $((COUNT+1)) >counter
My preference would be to do:
read COUNT <counter
echo $COUNT
echo $((COUNT+1)) >counter.$$
mv -f counter.$$ counter || exit 1
Even that won't ensure a correct count. It should at least avoid corrupting
the counter if there is more than one process involved.
--
|WARNING: Due to extreme spam, googlegroups.com is blocked. Due to ignorance |
| by the abuse department, bellsouth.net is blocked. If you post to |
| Usenet from these places, find another Usenet provider ASAP. |
| Phil Howard KA9WGN (email for humans: first name in lower case at ipal.net) |
.
- References:
- Increment counter upon each execution of shell script
- From: Myx
- Re: Increment counter upon each execution of shell script
- From: Ben Bacarisse
- Re: Increment counter upon each execution of shell script
- From: phil-news-nospam
- Increment counter upon each execution of shell script
- Prev by Date: Re: Will a signal interrupt a read(2) in it's middle way?
- Next by Date: Re: Error checking with execlp()
- Previous by thread: Re: Increment counter upon each execution of shell script
- Next by thread: Re: Increment counter upon each execution of shell script
- Index(es):
Relevant Pages
|