diod
Linux DIOD script
SHELL=/bin/bash PATH=/sbin:/bin:/usr/sbin:/usr/bin MAILTO=root HOME=/ # .---------------- Min (0 - 59) # | .------------- Hr (0 - 23) # | | .---------- DOM (1 - 31) # | | | .------- Mon (1 - 12) # | | | | .---- DOW (0 - 6) # | | | | | # Min Hr DOM Mon DOW User Command 0 * * * * root /usr/bin/find /root/diod/ -mindepth 1 -mtime +1
This is better than using /root/diod/* -mtime +1 because when there are no files inside /root/diod, cron will email you and complain with some stderr output from find
Ansible Task for Linux
- name: diod cron entry cron: name: diod minute: "0" job: "/usr/bin/find /root/diod/ -mindepth 1 -mtime +1 -delete"
Mac script for sleepy mac
Note that the placement of -mindepth 1 is very important on the mac.
# .---------------- Min (0 - 59) # | .------------- Hr (0 - 23) # | | .---------- DOM (1 - 31) # | | | .------- Mon (1 - 12) # | | | | .---- DOW (0 - 6) # | | | | | # Min Hr DOM Mon DOW Command 0 * * * * find /Users/justin/diod -mindepth 1 -mtime +1 -delete
Experiment with the mtime param. It is sometimes better to use mtime 1 instead of mtime +1, but to way to be sure without testing on your particular Mac.
See further here.
Windows DIOD script (diod.ps1)
[CmdletBinding()] param() # Get-ChildItem 'C:\Users\justin\Documents\diod' -recurse | Remove-Item -Recurse -Confirm:$false -verbose Get-ChildItem 'C:\Users\justin\Documents\diod' -recurse | Where {$_.LastWriteTime -lt (get-date).AddDays(-1)} | Remove-Item -Recurse -Confirm:$false -verbose Get-ChildItem 'C:\Users\justin\Documents\diow' -recurse | Where {$_.LastWriteTime -lt (get-date).AddDays(-7)} | Remove-Item -Recurse -Confirm:$false -verbose
Then make a scheduled task as follows:
Triggers: At 0400 every day Start a program: %SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe Add arguments: & "C:\portable_apps\scripts\diod\diod.ps1"