This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
aix:aix_crontab [2024/01/11 09:45] manu created |
aix:aix_crontab [2025/04/29 15:59] (current) manu |
||
---|---|---|---|
Line 7: | Line 7: | ||
Add crontab | Add crontab | ||
<cli prompt='#'> | <cli prompt='#'> | ||
- | echo '* * * * * /usr/bin/perl /opt/lpar2rrd-agent/lpar2rrd-agent.pl lnxmonitor01 > /var/tmp/lpar2rrd-agent1.out 2>&1' > /tmp/cron_lpar2rrd | + | [root@aixna001]/root# echo '* * * * * /usr/bin/perl /opt/lpar2rrd-agent/lpar2rrd-agent.pl lnxmonitor01 > /var/tmp/lpar2rrd-agent1.out 2>&1' > /tmp/cron_lpar2rrd |
- | su - lpar2rrd -c 'crontab /tmp/cron_lpar2rrd' | + | [root@aixna001]/root# su - lpar2rrd -c 'crontab /tmp/cron_lpar2rrd' |
</cli> | </cli> | ||
===== Check crontab ===== | ===== Check crontab ===== | ||
+ | List crontab for a user | ||
<cli prompt='>'> | <cli prompt='>'> | ||
[root@aixna001]/root> crontab -l lpar2rrd | [root@aixna001]/root> crontab -l lpar2rrd | ||
0 1 * * * /usr/bin/perl /opt/lpar2rrd-agent/lpar2rrd-agent.pl lnxmonitor01 > /var/tmp/lpar2rrd-agent.out 2>&1 | 0 1 * * * /usr/bin/perl /opt/lpar2rrd-agent/lpar2rrd-agent.pl lnxmonitor01 > /var/tmp/lpar2rrd-agent.out 2>&1 | ||
+ | 40 18 * * 1,2,3,4,5 ( . /home/lpar/.bash_profile ; /myscript/script01.sh ) >/dev/null 2>&1 | ||
+ | </cli> | ||
+ | Check latest appied crontab | ||
+ | <cli prompt='>'> | ||
[root@aixna001]/root> crontab -v lpar2rrd | [root@aixna001]/root> crontab -v lpar2rrd | ||
Crontab file: lpar2rrd Submission time: Thu Jan 11 09:32:45 CET 2024 | Crontab file: lpar2rrd Submission time: Thu Jan 11 09:32:45 CET 2024 | ||
</cli> | </cli> | ||
+ | |||
+ | Fields description | ||
+ | * minute: 0 through 59 | ||
+ | * hour: 0 through 23 | ||
+ | * day_of_month: 1 through 31 | ||
+ | * month: 1 through 12 | ||
+ | * weekday: 0 through 6 for Sunday through Saturday | ||
+ | |||
+ | FIXME | ||
+ | On linux (NOT AIX) you can also use for very 10 minutes, */10 | ||
+ | 0,10,20,30,40,50 6 * * 1-5 /usr/bin/calendar | ||
+ | */10 * * 1-5 /usr/bin/calendar | ||
+ | |||
+ | ==== Cron log ==== | ||
+ | |||
+ | Default log output is located in**/var/adm/cron/log** | ||
+ | |||
+ | You can use logrotate mechanism to rotate this log, or choose the following steps | ||
+ | |||
+ | === Crontab and log management === | ||
+ | |||
+ | By default on AIX cron process use the file **/etc/cronlog.conf** to customize cronlog.\\ | ||
+ | In this file you can easily rotate cron logfile. | ||
+ | |||
+ | To log information in directory /var/cronjobs, log file cron.out, size of 50k, total number of rotated files = 4, archive in /var/cronarch, archive files with compression, create the configuration file as follows: | ||
+ | |||
+ | <cli prompt='>'> | ||
+ | [root@aix001] /root> cat /etc/cronlog.conf | ||
+ | ... | ||
+ | logfile=/var/cronjobs/cron.out | ||
+ | size=50K | ||
+ | rotate=4 | ||
+ | archive=/var/cronarch | ||
+ | compress | ||
+ | </cli> | ||
+ | |||
+ | ==== Errors ==== | ||
+ | |||
+ | I found that the log is located in **/var/adm/log**. Further we are getting this error repeatedly ever since this date/time. How do I clear this max limit? | ||
+ | c queue max run limit reached Fri Nov 25 21:52:00 2016 | ||
+ | ! rescheduling a cron job Fri Nov 25 21:52:00 2016 | ||
+ | | ||
+ | The cron daemon has a limit of how many jobs it can run simultaneously. By default it is 100 jobs. If a new job is scheduled to run, and the limit has already been reached, the job will be rescheduled at a later time (the default is 60 seconds later). Both the number of jobs and wait time are configured in the file **/var/adm/cron/queuedefs**. | ||
+ | |||
+ | To do this, add an entry to the bottom of the /var/adm/cron/queuedefs file using an editor such as vi. The entry should have the form: | ||
+ | c.50j20n60w | ||
+ | where | ||
+ | * c. = The "c" or cron queue, followed by a period separator. | ||
+ | * Nj = The maximum number of jobs to be run simultaneously by cron, followed by the letter "j". | ||
+ | * Nn = The "nice" value of the jobs to be run (default is 2), followed by the letter "n". | ||
+ | * Nw = The time a job has to wait until the next attempt to run it, followed by the letter "w". | ||
+ | |||
+ | For example: | ||
+ | This example would set the cron queue to a maximum of 200 jobs, with a nice value of 2, and a wait time of 60 seconds. | ||
+ | <cli prompt='#'> | ||
+ | root@orathal-test /var/tmp# cat /var/adm/cron/queuedefs | ||
+ | c.200j2n60w | ||
+ | </cli> | ||
+ | |||
+ | c.200j2n60w | ||