Macos shell脚本在日期删除
我可能会使用cron来运行上面的脚本,但我认为可能有更好的方法 因为我想包括这一部分Macos shell脚本在日期删除,macos,bash,shell,cron,Macos,Bash,Shell,Cron,我可能会使用cron来运行上面的脚本,但我认为可能有更好的方法 因为我想包括这一部分 #!/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/ -
#!/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/
如何每两周实现一次(#rm-rf/path/to/directory/.hiddenStuffz)
只需将它写入另一个脚本,并在cron中运行它,或者我可以在一个脚本中实现这一切。您可以使用您的脚本来实现这一点。在您的crontab中:
- 第一行:把你的脚本
- 第二行:在月日的“/bin/rm-rf/path/to/directory/.hiddenStuffz”行中加上1,15
#rm -rf /path/to/directory/.hiddenStuffz