add cron tips

add del_logs.sh
This commit is contained in:
TheK4n 2021-10-02 01:05:04 +03:00
parent 02035855bf
commit 3a8d749ad6
2 changed files with 27 additions and 0 deletions

View File

@ -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
View 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