I'm on Centos 6. I have a directory full of xml files that I want to perform an edit on and then rsync or move them to another directory on the same server.
How would I go about doing that and then set it up as a cronjob to run continuously?
ADDITIONAL INFO:
I guess my question is more of: how do I have cron run a php script and then when it's done (only when it's done) rsync or mv the file to another directory. I don't want the php script to be moved, just the files that the php script edited.
This is a sample of what I'd be editing. I want to add an absolute path to each media-reference source:
<media media-type="image"> <media-reference source="8084413.jpg" /> <media-caption>blah</media-caption> </media> <media media-type="image"> <media-reference source="8084411.jpg" /> <media-caption>blah</media-caption> </media> <media media-type="image"> <media-reference source="8084414.jpg" /> <media-caption>blah</media-caption> </media>
You can stuff a lot into a cron entry, but it's tidier to encapsulate it in a script:
#!/bin/sh
cd /relevant/directory
touch marker_file
php /path/to/script.php *.xml
find . -name \*.xml -newer marker_file -exec mv {} /destination \;
rm marker_file
Then in cron, to run hourly:
0 * * * * /path/to/above/script
Edit your cron file with one of below:
crontab -e
crontab -l > ~/crontab; edit ~/crontab; crontab ~/crontab