Since you're already looking at the idea of file existence checks, similar ideas can be offered as well as some new ones.
1)
File w/ pid written in at start of script1 - not a bad idea and while PIDs can be reused, the chance of said PID to be reused that soon is pretty unlikely (in my experience). A modification to this would be to ensure that the file is deleted upon exit or die of script1 and script2 checking the existence of the PID in script1's file in the proc table.
2)
Script1 can set a global variable along with item 1 - slightly more error-checking w/o going into IPC manipulation. Have script1 fire off a global variable like SCRIPT1_START=1 and have script2 check the file for the PID as well as whether SCRIPT1_START is 1 (running) or 0 (not running) or even 2 (error encountered, script1 died w/o cleanup, etc). This way, you can check said variable at the start of script2 and know what status script1 is in.
While other ideas and concepts are much more cleaner, these are just simple Q&D's that might provide what you're looking for. This situation is very similar to the TeamSpeak server status/starts we're working with to ensure that cleanup happens and the next start is successful. Hope this helps and any constructive criticism regarding what I've posted is welcome.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.