mirror of
https://github.com/fritz-smh/yi-hack.git
synced 2026-08-11 16:33:00 +00:00
@@ -18,9 +18,40 @@ Source of the script :
|
||||
* https://github.com/fritz-smh/yi-hack/pull/24
|
||||
* http://4pda.ru/forum/index.php?showtopic=638230&st=2780#entry44208114
|
||||
|
||||
cleanup.sh
|
||||
==========
|
||||
delete_old_videos.sh
|
||||
====================
|
||||
|
||||
This script will cleanup video files older than 15 days.
|
||||
|
||||
You need to add it in the crontab
|
||||
This script searchs and deletes videos older than 15 days. (You can change this value if you configure the script)
|
||||
You have to run it manually or add it to crontab for running it autmatically.
|
||||
The camera might throw an error if you try to run "crontab -e":
|
||||
```sh
|
||||
crontab -e
|
||||
crontab: chdir(/var/spool/cron/crontabs): No such file or directory
|
||||
```
|
||||
If that's the case just create that dir manually and you can edit the crontab with "crontab -e"
|
||||
Example configuration of crontab (runs the script the 15th of each month):
|
||||
```sh
|
||||
# Edit this file to introduce tasks to be run by cron.
|
||||
#
|
||||
# Each task to run has to be defined through a single line
|
||||
# indicating with different fields when the task will be run
|
||||
# and what command to run for the task
|
||||
#
|
||||
# To define the time you can provide concrete values for
|
||||
# minute (m), hour (h), day of month (dom), month (mon),
|
||||
# and day of week (dow) or use '*' in these fields (for 'any').#
|
||||
# Notice that tasks will be started based on the cron's system
|
||||
# daemon's notion of time and timezones.
|
||||
#
|
||||
# Output of the crontab jobs (including errors) is sent through
|
||||
# email to the user the crontab file belongs to (unless redirected).
|
||||
#
|
||||
# For example, you can run a backup of all your user accounts
|
||||
# at 5 a.m every week with:
|
||||
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
|
||||
#
|
||||
# For more information see the manual pages of crontab(5) and cron(8)
|
||||
#
|
||||
# m h dom mon dow command
|
||||
0 0 15 * * /home/hd1/test/scripts/delete_old_videos.sh
|
||||
```
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
#!/bin/sh
|
||||
#Delete files and folders more than 15 days
|
||||
|
||||
dir="/home/hd1/record/"
|
||||
days=+15
|
||||
dt=`date +%y%m%d`
|
||||
#echo $dir
|
||||
#echo $days
|
||||
#echo $dt
|
||||
#Command:
|
||||
du -sh ${dir} > ${dir}Delete_$dt.log
|
||||
find ${dir} -mtime $days -exec rm -Rf {} \;
|
||||
du -sh ${dir} >> ${dir}Delete_$dt.log
|
||||
echo "Works!"
|
||||
@@ -0,0 +1,14 @@
|
||||
#!/bin/sh
|
||||
#Delete files and folders more than 15 days
|
||||
#To run this script you can make an entry the cameras crontab
|
||||
#You might need to create manually the folder structure /var/spool/cron/crontabs
|
||||
#or when you try to add a crontab with "crontab -e" it might give you an error
|
||||
#search on internet about the use of crontab
|
||||
|
||||
dir="/home/hd1/record/"
|
||||
days=+15
|
||||
dt=`date +%y%m%d`
|
||||
|
||||
du -sh ${dir} > ${dir}Delete_$dt.log
|
||||
find ${dir} -mtime $days -exec rm -Rf {} \;
|
||||
du -sh ${dir} >> ${dir}Delete_$dt.log
|
||||
Reference in New Issue
Block a user