Sponsored Content
Top Forums Shell Programming and Scripting Building a better mouse trap, or How many lines of code does it take to trap a mouse? Post 302070670 by mph on Thursday 6th of April 2006 01:49:18 PM
Old 04-06-2006
Building a better mouse trap, or How many lines of code does it take to trap a mouse?

Hello all,

I'm hoping to get a little insight from some of the wily veterans amongst you.

I've written a script to check for new outgoing files to our vendors located on our ssl server. It seems to be working ok, but the final question here, will be one of logic, and/or a better way to do it.

First a little background; The program is run every 5 minutes from cron. The files are uploaded via NFS or CIFS. So file dates can't be fully trusted. So, I use find -cmin for the dates. Files remain on the server for 10 days.

Process;
1) Check for PID file. If PID file exist, exit. (program still running) If not generate PID file.

2) Check filesystem size for changes since the last run. If no changes, clean up PID file and exit. (No new files) If changed sleep 1 minute. (File(s) may still be transferring) Loop until changes stop. Add total sleep time to find time. Continue to step 3 (Transfer done)

3) Using the find command. Build a file containing the list of new files in ftp directory newer than specified cmin time.

4) Filter through the file built in step 3. Generate email for each vendor with file names and send to contact for vendor.

5) Clean up PID file. Copy stat files to backups for comparison on the next program run. exit.

Like I said, this is working, but a few files slip through the cracks.

What I would like to know is: If you have any thoghts on better ways to do this.

One Idea I've been looking into is:
Generate a full file list every 5 minutes and use diff to generate the outgoing file list?

Also, This started out as a small server. So, checking for filesystem changes was no problem. Now I have roughly 180 vendors accessing the site. With all the changes to the filesystem size the program will somtimes run for 15 - 20 minutes. Regardless of how the list is built. I would think that once it is generated I could just check file sizes on those files for changes. Once they finish transferring, generate the mail, and wait for the next go-round to pick up additional files.

So what's the general consensus? Thoughts, Ideas, Opinions?

Thanks in Advance,
MPH

I'd rather have a bottle in front of me, than a frontal labotomy.
 

8 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Mouse wheel...

Hello. I've got round to installing RedHat 7.1, and i have this slight problem. I'm not able to use my mouse wheel. Is this just not possible in RedHat or is there a way to configure my mouse so i can use my mouse wheel. Thank you. (1 Reply)
Discussion started by: Mr-Pixie
1 Replies

2. Linux

Mouse Problems

I just got the other computer working again and i put Fedora Core 2 on it but theres a problem. It wont recongnize my mouse at all. Not in installation or in the actual desktop... it doesnt even know its there. It says No - Mouse.... does anyone know how i can fix this? (4 Replies)
Discussion started by: FordGuy
4 Replies

3. UNIX for Advanced & Expert Users

Indigo mouse

A few years ago i found i the Net a "homework" about how to convert ps2 mouse to Indigo mouse. But i do not save it. Anybody helps me? There are about 10 Indigo mice in all of my country. Thanks in advance (2 Replies)
Discussion started by: mikidimov
2 Replies

4. HP-UX

reset mouse

I have a Belkin KVM switcher, but when I switch from Unix to Windows, then back to Unix, the mouse stops working is there any way to reset the mouse without restarting the workstation? thanks! (0 Replies)
Discussion started by: xRonin
0 Replies

5. UNIX for Dummies Questions & Answers

Changing middle mouse button for pasting to right mouse button in cygwin rxvt

Hi, I'm using rxvt in Cygwin and I'm wondering how to change my mouse bindings from the middle button for pasting to the right button. The main reason why I want to do this is because my laptop doesn't have a middle mouse button. Thanks for any help! (2 Replies)
Discussion started by: sayeo
2 Replies

6. Shell Programming and Scripting

Cntl+z Trap is not detecting ??? Help required to add a trap detection ???

Hi folks, I have tried to add some trap detection in the below script....this script is used to monitor database activities...in a rather awkward way :rolleyes:.... The idea behind adding trap is that....this script creates lots of temporary files in the running folder to store the count... (1 Reply)
Discussion started by: frozensmilz
1 Replies

7. What is on Your Mind?

Keyboard vs mouse

Which Input device do you use the most ? for me... keyboard ofcourse !! (56 Replies)
Discussion started by: vpraveen84
56 Replies

8. Homework & Coursework Questions

VM trap may work differently than a pure install trap.

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: That is the last reply I received from my instructor, and I'm looking for some alternatives. When using... (2 Replies)
Discussion started by: newuser45
2 Replies
lockfile-progs(1)						 Lockfile programs						 lockfile-progs(1)

NAME
lockfile-progs - command-line programs to safely lock and unlock files and mailboxes (via liblockfile). SYNOPSIS
mail-lock [--use-pid] [--retry retry-count] mail-unlock mail-touchlock [--oneshot] lockfile-create [--use-pid] [--retry retry-count] [--lock-name] filename lockfile-remove [--lock-name] filename lockfile-touch [--oneshot] [--lock-name] filename lockfile-check [--use-pid] [--lock-name] filename DESCRIPTION
Lockfile-progs provides a set a programs that can be used to lock and unlock mailboxes and files safely (via liblockfile): mail-lock - lock the current user's mailbox mail-unlock - unlock the current user's mailbox mail-touchlock - touch the lock on the current user's mailbox lockfile-create - lock a given file lockfile-remove - remove the lock on a given file lockfile-touch - touch the lock on a given file lockfile-check - check the lock on a given file By default, the filename argument refers to the name of the file to be locked, and the name of the lockfile will be filename .lock. How- ever, if the --lock-name argument is specified, then filename will be taken as the name of the lockfile itself. Each of the mail locking commands attempts to lock /var/spool/mail/<user>, where <user> is the name associated with the effective user ID, as determined by via geteuid(2). Once a file is locked, the lock must be touched at least once every five minutes or the lock will be considered stale, and subsequent lock attempts will succeed. Also see the --use-pid option and the lockfile_create(3) manpage. The lockfile-check command tests whether or not a valid lock already exists. OPTIONS
-q, --quiet Suppress any output. Success or failure will only be indicated by the exit status. -v, --verbose Enable diagnostic output. -l, --lock-name Do not append .lock to the filename. This option applies to lockfile-create, lockfile-remove, lockfile-touch, or lockfile-check. -p, --use-pid Write the current process id (PID) to the lockfile whenever a lockfile is created, and use that pid when checking a lock's validity. See the lockfile_create(3) manpage for more information. This option applies to lockfile-create, lockfile-remove, lockfile-touch, and lockfile-check. -o, --oneshot Touch the lock and exit immediately. This option applies to lockfile-touch and mail-touchlock. When not provided, these commands will run forever, touching the lock once every minute until killed. -r retry-count, --retry retry-count Try to lock filename retry-count times before giving up. Each attempt will be delayed a bit longer than the last (in 5 second incre- ments) until reaching a maximum delay of one minute between retries. If retry-count is unspecified, the default is 9 which will give up after 180 seconds (3 minutes) if all 9 lock attempts fail. EXAMPLES
Locking a file during a lengthy process: lockfile-create /some/file lockfile-touch /some/file & # Save the PID of the lockfile-touch process BADGER="$!" do-something-important-with /some/file kill "${BADGER}" lockfile-remove /some/file EXIT STATUS
0 For lockfile-check this indicates that a valid lock exists, otherwise it just indicates successful program execution. Not 0 For lockfile-check a non-zero exit status indicates that the specified lock does not exist or is not valid. For other programs it indicates that some problem was encountered. SEE ALSO
maillock(3) touchlock(3) mailunlock(3) lockfile_create(3) lockfile_remove(3) lockfile_touch(3) lockfile_check(3) AUTHOR
Written by Rob Browning <rlb@defaultvalue.org> 0.1.12 2008-02-10 lockfile-progs(1)
All times are GMT -4. The time now is 07:51 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy