add cron tips
add del_logs.sh
This commit is contained in:
parent
02035855bf
commit
3a8d749ad6
10
README.md
10
README.md
@ -106,4 +106,14 @@ sudo systemctl status <service>.service
|
|||||||
sudo systemctl enable <service>.service
|
sudo systemctl enable <service>.service
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Cron
|
||||||
|
|
||||||
|
```crontab -e```
|
||||||
|
|
||||||
|
```0 0 1 1 * command.sh``` - Every year in 1 January 00:00:00 \
|
||||||
|
```*/1 * * * * command.sh``` - Every minute\
|
||||||
|
```0 */3 * * 2,5 command.sh``` - One time per 3 hours in Tue and Fri\
|
||||||
|
```0 0,12 1 */2 * command.sh``` - At minute 0 past hour 0 and 12 on day-of-month 1 in every 2nd month
|
||||||
|
|
||||||
|
|
||||||
<h1 align="center"><a href="#top">▲</a></h1>
|
<h1 align="center"><a href="#top">▲</a></h1>
|
||||||
|
|||||||
17
functions/del_logs.sh
Normal file
17
functions/del_logs.sh
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#!/usr/bin/bash
|
||||||
|
|
||||||
|
# removes log files with size greater then 100Mb
|
||||||
|
|
||||||
|
for i in $(sudo du -a /var/log/* | sort -hr | tr '\t' ':')
|
||||||
|
do
|
||||||
|
|
||||||
|
size_file=( $(echo "$i" | tr ':' ' ') )
|
||||||
|
|
||||||
|
size="${size_file[0]}"
|
||||||
|
file="${size_file[1]}"
|
||||||
|
|
||||||
|
if [ "$size" -ge 102400 ] && [ -f "$file" ]; then
|
||||||
|
sudo rm "$file"
|
||||||
|
fi
|
||||||
|
|
||||||
|
done
|
||||||
Loading…
x
Reference in New Issue
Block a user