Tuesday, February 4, 2014
Configure crontab (UNIX/Linux)
If you are about to modify a crontab, it's better to keep a backup:
In command line:
> crontab -l > /home/usr/crontab_[Modification date : YYYY_MM_DD_hh_mm]_bk
To modify the crontab, you first need to create a copy of the actual configuration:
> crontab -l > /home/usr/crontab_current.txt
# .------------------- minute (0 - 59)
# | .--------------- hour (0 - 23)
# | | .----------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan, feb, mar, apr ...
# | | | | .--- day of week (0 - 6, Sunday = 0) OR sun, mon, tue, wed, thu, fri, sat
# | | | | |
# * * * * * command to be executed
# Operators : * = all
# , = and
# - = to
#
# Everyday of the week: 3:40, 7:40, 12:40, 16:40 and 22:40
40 3,7,12,16,22 * * * /application/script/run_refresh.sh param1 param2 > /dev/null
When the modification is over,
> crontab /home/usr/crontab_current.txt
If you are modifying the file in Windows, don't forget to convert the EOL:
> dos2unix /home/usr/crontab_current.txt /home/usr/crontab_current.txt
If you want to periodicaly delete log files, you can add this to the crontab:
> find /opt/logs -name "*.log" -type f -mtime +1 -delete
Subscribe to:
Post Comments (Atom)
Blog Archive
-
▼
2014
(38)
-
▼
February
(12)
- bash
- Configure crontab (UNIX/Linux)
- Commit Monitor - Install (Windows)
- Cntlm - Install (Windows)
- Node.js configure proxy (HTTP/HTTPS)
- Adding a folder to the PATH (Windows)
- Creating an environment variable (Windows)
- Analog - Filter
- Analog - Install (Windows)
- Links
- S.O.L.I.D
- Port already in use (Windows)
-
▼
February
(12)
No comments:
Post a Comment