Code: Select all
#!/bin/sh
find /home/pi/delete/*.log -mtime +30 -exec rm {} \;
Code: Select all
#!/bin/sh
find /home/pi/delete/*.log -mtime +30 -exec rm {} \;
Its better to rotate your log files rather than deleting them; then, maybe after so many rotations (or so many weeks) delete the oldest rotation.expandables wrote:Hi i have a script that deletes files in 30 days it works but i want to know how can i delete a file on a specific date .
touch -t 201506010000 /home/pi/delete/filetime # June 1st @ midnightexpandables wrote:Code: Select all
#!/bin/sh find /home/pi/delete/*.log -mtime +30 -exec rm {} \;
I suppose something along the lines of:expandables wrote:How can i do a script that checks if 30 days has pass from a specific date and then delete a file?
Code: Select all
#!/bin/bash
now=$( date +%s)
then="2015-05-31"
testdate=$( date -d "$then + 30 days" +%s )
if [ $now -gt $testdate ]
then
echo "Now is more than 30 days from $then"
fi