0

I have the following problem: I make some automated changes in my webserver config (through a web interface) and I want to restart the apache. Since none of the actions are performed by root I cannot start the server directly.

My current workaround is to have a cronjob(every minute) for root that checks if a specific file exists (/tmp/restart.txt). If the file exists, it is deleted and the apache is restarted.

This can be invoked by other users by simply touching the file

$ touch /tmp/restart.txt

My question now is: Can I avoid the cronjob and somehow create a listener that gets invoked everytime the mtime of the file changes? This would be a better solution in my opinion.

2 Answers 2

1

We are using iwatch to monitor file changes on our servers. It uses inotify, which is included in Linux kernels >= 2.6.13 and depends on Perl, but I guess this should be available if you are running a Linux box.

iwatch -c "File %f changed >> /tmp/changed.txt" -e modify /path/to/monitor

-c specifies the command to execute, -e specifies the events to watch for (all in the documentation). The /path/to/monitor can be a directory or file.

0

cronjob doing this would be slightly more secure:

find /path/to/httpd.conf -newer /tmp/ars.dat -exec "/path/to/apache.rc restart;" -exec "touch -m /tmp/ars.dat;"

Putting the reference file somewhere other than tmp would probably be a good idea too.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .