Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've got a cronjob that runs every minute and checks existence of a certain file. If there's no such file, job silently ends. If there is a file, then another script is started. That script removes the file when done. Its execution time can take up to 20 minutes.

My questions are: Are there any flaws in this scheme? Is it ok to store such file in tmp? Can I be shure that nothing will attempt to remove it?

Thanks for replies!

This scheme purpose is to allow to run that script through the web interface. Script itself is in user's home folder and works on its contents. I'm not sure if creating pid files in /var/run is appropriate.

share|improve this question
Is the purpose of this scheme to have one copy of the second process running and to ensure that the second process is run almost continuously ? – Iain Jun 1 '10 at 15:22
If you just want to make sure that that file is always deleted ASAP, you may be better off using inotify. – intuited Jun 1 '10 at 15:44
up vote 2 down vote accepted

I guess you speak of a Linux system. If you did not set up anything to clean up /tmp, it will not be done automatically. The only exception is when you reboot the system - most Linux distros clean up /tmp at reboot. Of course you can search for the script that does the celan up and you can disable it if this is a concern

share|improve this answer
Fedora/Redhat install tmpwatch by default which clears files from /tmp after 10 days and /var/tmp after 30 days. Debian/Ubuntu do it at reboot. – James Jun 1 '10 at 16:57

First... I think your job may run up to 20 times if you 'remove the file when done'. From what you're saying the file should be moved/removed once it's detected.

A similar question is asked here.

share|improve this answer

As along as you're checking to make sure that your file-processing script isn't already running, then you should be fine. /tmp is fine for this sort of thing, unless you're experiencing random reboots, and that's a pretty big problem on it's own.

share|improve this answer

You may want to look at the hier man page. This kind of flag is often found in /var/run. You should use a marker file for both processes to prevent multiple processing scripts from running.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.