Answer the question
In order to leave comments, you need to log in
Human-readable logging of cron jobs?
Hello. There was one problem - once a day the load on the server is greatly increased.
Because this is repeated at the same time - suspicion falls naturally on tasks launched by cron. The task is to track what exactly creates a large load in order to optimize it.
Because We have a lot of tasks in the crown, different scripts are launched, it will take quite a long time to add some kind of logging system of our own, I want to add something within a couple of hours in order to track it today and start fixing it tomorrow.
Perhaps there is some kind of logging system that can at least log everything that is launched by cron and, ideally, somehow combine this with displaying the load by tasks? Or maybe someone has other ideas?
Thanks in advance.
Answer the question
In order to leave comments, you need to log in
Wait, so you know the time this is happening? Why can't you just see what exactly was running at that moment?
Cron writes everything to syslog. grep CRON /var/log/syslog and find the right time.
Or do you have such a large kroner that a hundred tasks per minute are launched there?
want to add something in a couple of hours
#!/bin/bash
date 2>&1 >> /var/log/task1
time /bin/task1 2>&1 >> /var/log/task1
cat /proc/meminfo >> /var/log/task1
cat /proc/loadavg >> /var/log/task1
1. For processes run by cron, the parent process is called CRON and its ppid corresponds to the cron process. Example:
root 514 1 0 Aug 10 ? 00:00:00 cron ... root 21227 514 0 17:30 ? 00:00:00 CRON root 21228 21227 0 17:30 ? 00:00:00 /bin/sh -c sleep 1
ps u -p <pid>
you can write a script on your knee that calls all the cron commands, like this:
#!/bin/sh
/bin/date >> /var/log/smth
"[email protected]"
/bin/date >> /var/log/smth
/usr/bin/uptime >> /var/log/smth
/usr/bin/iostat -x 1 1 >> /var/log/smth
Choose what you want. There are many options ;)man time
The solution is to write to the same file, and not output : [ -o FILE ] [ --append ] that is,
time -o /var/log/log --append command
Sorry, I wrote from memory, now I'm out time outputs to the console and not to stder ;)
And what prevents you from entering the server at this time and seeing the top?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question