Gabriel Perry

Greenhorn
+ Follow
since Jul 26, 2004
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Gabriel Perry

thanks for your help. i'll give these suggestions a try.

g
19 years ago
yea, i suppose, but i'm wondering if there is a way to do this from within java and not using Runtime.exec() (not running a shell or perl)
19 years ago
i've got a cron job set to call this java app every minute. this app looks in a directory for some files, if it finds the files it's looking for then it does some processing on them. if it doesn't find the files, it quits.

i need a way to prevent other java processes from interferring with this, uh, process. so the initial java app looks to see if a lock file exists in the search directory. if it doesn't then it creates one and stores its PID in it.

why? because if another java process comes in and sees the lock file, it will get the stored PID and look to see if it exists in /proc if it does, it knows to get out, if it doesn't find the PID in /proc, then it knows that it can ignore the lock file, that is, the lockfile is bad (leftover from a process that is no longer running.)

does this give you a reasonable idea what i'm trying to accomplish?
19 years ago
obviously, this is a platform specific question, i'm running a java app on a unix/linux platform and want the store the PID in a kind of lock file. does one know how to do this?

i searched around cyberland a bit and read that one can use Runtime.exec() to execute the following perl command...

perl -e 'print getppid()."\n";'

but i'm wondering if there is a better way to do this. for instance, can one use some of the capabilities in the reflection API?
19 years ago