Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 need the CentOS system to automatically delete some files (if they exist) on every boot.

I can write a PHP or bash script to actually delete the files, but how can I get the script to run on each boot?

The reason is that I have some PHP crons that run with a lock file, if the system shuts down un-expectantly or suddenly due to a power failure the lock files will still exist.

share|improve this question
up vote 0 down vote accepted

The /etc/rc.d/rc.local script is executed by the init command at boot time or when changing runlevels. Adding commands to the bottom of this script is an easy way to perform necessary tasks like starting special services or initialize devices without writing complex initialization scripts in the /etc/rc.d/init.d/ directory and creating symbolic links.

centOS documentation 30.3 Running Additional Programs at Boot Time

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.