I forgot to say, there is already a script which may do what you need here:
Edit: Doesn't use a marker file like I thought. I must be confusing it with something else. But it may still be of interest.
I forgot to say, there is already a script which may do what you need here:
Edit: Doesn't use a marker file like I thought. I must be confusing it with something else. But it may still be of interest.