Question

#!/bin/bash
NOW=$(date +"%Y-%m-%d-%H-%M-%S")
FILE="STUFF_2BeDeleted_$NOW.txt"
echo "Writing txt data to STUFF_2BeDeleted_$NOW.txt file, please wait..."
# rest of script
find /path/to/directory/stuffzMovin/ -type f -mmin +10 -print0 | xargs -0 ls -ltr > /path/to/directory/STUFF_2BeDeleted_$NOW.txt
mv -v /path/to/directory/stuffzMovin/* /path/to/directory/.hiddenStuffz/

i would probably use cron to run the above script, but i think there may be a better way because i would like to include this part

#rm -rf /path/to/directory/.hiddenStuffz

How can i make this happen every 2 weeks (#rm -rf /path/to/directory/.hiddenStuffz) just write it to another script and run that in cron also - or could i make this all happen in 1 script.

Was it helpful?

Solution

You can do this with your script. In your crontab :

  • first line : put your script
  • second line : put your '/bin/rm -rf /path/to/directory/.hiddenStuffz' line with 1,15 for the day of month.

When you use cron, you should take care to variable environments.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top