crontab tasks are accumilating
While checking the status of cron service, could see around 160 tasks are in queue, couldn't clear them by stopping and starting the cron service.
How to clear the queued cron task in ubuntu.
Thanks in advance.!
Question information
- Language:
- English Edit question
- Status:
- Answered
- For:
- Ubuntu Edit question
- Assignee:
- No assignee Edit question
- Last query:
- Last reply:
Revision history for this message
|
#1 |
What is the output of:
ps -ef | grep cron; lsb_release -a; uname -a
Thanks
Revision history for this message
|
#3 |
What is the output of the commands
systemctl status cron
sudo ls -la /var/spool/
(You are free to obfuscate details that you want to keep secret, as long as the gist stays readable.)
Remark:
I am a bit astonished to see a quite old version of the kernel (4.4.0-31). Current version is 4.4.0-200
Revision history for this message
|
#4 |
Thanks for the update, will look into kernel version.
Please find the details below,
root@bd-server1:~# ps -ef | grep cron; lsb_release -a; uname -a
root 4396 1 0 Jan06 ? 00:00:04 /usr/sbin/cron -f
root 19845 19829 0 12:20 pts/27 00:00:00 grep --color=auto cron
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.6 LTS
Release: 16.04
Codename: xenial
Linux bd-server1.com 4.4.0-31-generic #50-Ubuntu SMP Wed Jul 13 00:07:12 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
root@bd-server1:~# systemctl status cron
● cron.service - Regular background program processing daemon
Loaded: loaded (/lib/systemd/
Active: active (running) since Wed 2021-01-06 00:34:08 IST; 1 weeks 6 days ago
Docs: man:cron(8)
Main PID: 4396 (cron)
Tasks: 167
Memory: 44.4M
CPU: 1h 53min 50.866s
CGroup: /system.
├─ 356 /bin/sh /home/oracle/
├─ 431 /bin/sh /home/oracle/
├─ 580 /bin/sh /home/oracle/
├─ 582 /bin/sh /home/oracle/
├─ 771 /bin/sh /home/oracle/
├─ 967 /bin/sh /home/oracle/
├─ 1200 /bin/sh /home/oracle/
├─ 1653 /bin/sh /home/oracle/
.
.
.
.
├─31552 /bin/sh /home/oracle/
├─31889 /bin/sh /home/oracle/
├─32577 /bin/sh /home/oracle/
└─32641 /bin/sh /home/oracle/
Jan 19 12:17:01 bd-server1.com CRON[19643]: (barman) CMD ([ -x /usr/bin/barman ] && /usr/bin/barman -q cron)
Jan 19 12:17:01 bd-server1.com CRON[19640]: pam_unix(
Jan 19 12:18:01 bd-server1.com CRON[19665]: pam_unix(
Jan 19 12:18:01 bd-server1.com CRON[19666]: (barman) CMD ([ -x /usr/bin/barman ] && /usr/bin/barman -q cron)
Jan 19 12:19:01 bd-server1.com CRON[19685]: pam_unix(
Jan 19 12:19:01 bd-server1.com CRON[19686]: (barman) CMD ([ -x /usr/bin/barman ] && /usr/bin/barman -q cron)
Jan 19 12:19:02 bd-server1.com CRON[19685]: pam_unix(
Jan 19 12:20:01 bd-server1.com CRON[19758]: pam_unix(
Jan 19 12:20:01 bd-server1.com CRON[19759]: (barman) CMD ([ -x /usr/bin/barman ] && /usr/bin/barman -q cron)
Jan 19 12:20:01 bd-server1.com CRON[19758]: pam_unix(
root@bd-server1:~# sudo ls -la /var/spool/
total 12
drwx-wx--T 2 root crontab 4096 Jan 6 00:36 .
drwxr-xr-x 5 root root 4096 Dec 24 2018 ..
-rw------- 1 oracle crontab 2727 Jan 6 00:36 oracle
Revision history for this message
|
#5 |
Are those backup jobs still running?
e.g. do you see them with
ps ax | grep "/bin/sh /home"
Eventually there is a problem with the backup jobs that keeps them running forever instead of ending.
Revision history for this message
|
#6 |
for your question, yes.
Initially we stopped all schedules for couple of days. then after again enabled.
ps ax | grep "/bin/sh /home"
356 ? D 0:00 /bin/sh /home/oracle/
431 ? D 0:00 /bin/sh /home/oracle/
580 ? D 0:00 /bin/sh /home/oracle/
582 ? D 0:00 /bin/sh /home/oracle/
771 ? D 0:00 /bin/sh /home/oracle/
967 ? D 0:00 /bin/sh /home/oracle/
1200 ? D 0:00 /bin/sh /home/oracle/
yes, your are right. But same script is running fine in other machines.
Revision history for this message
|
#7 |
Is there any way to clear all crontab tasks and restarting the cron service.
Stopping cron service and staring not clearing the Queue of TASKS.
Revision history for this message
|
#8 |
Could kill the PIDs. I suggest you add lines to the script to echo text to a file on the system so that you can read it and see where it stops and hangs
Revision history for this message
|
#9 |
Killing PIDs not worked.
Backups are running now without any issues. But couldn't clear the past cron TASK's queue.
Any other ways, I can get here.
Revision history for this message
|
#10 |
What happens if you issue the command
kill 356 431 580
or (if this gives a "not authorized")
sudo kill 356 431 580
or eventually
sudo kill -SIGHUP 356 431 580
etc.
Revision history for this message
|
#11 |
We got no issues while killing those PID's, Please find the below details. kill with SIGHUP also didn't work.(details added below)
oracle@
oracle@
oracle 356 1 0 2020 ? 00:00:00 /bin/sh /home/oracle/
oracle 8289 8241 0 10:10 pts/26 00:00:00 grep --color=auto 356
oracle 23562 1 0 2020 ? 00:00:00 /bin/sh /home/oracle/
oracle@
oracle 431 1 0 2020 ? 00:00:00 /bin/sh /home/oracle/
oracle 4314 1 0 2020 ? 00:00:00 /lib/systemd/
oracle 4315 4314 0 2020 ? 00:00:00 (sd-pam)
oracle 8292 8241 0 10:10 pts/26 00:00:00 grep --color=auto 431
oracle@
oracle 580 1 0 2020 ? 00:00:00 /bin/sh /home/oracle/
oracle 4580 1 0 2020 ? 00:02:25 ora_p005_BDAPX20
oracle 8295 8241 0 10:10 pts/26 00:00:00 grep --color=auto 580
-------
oracle@
oracle@
oracle@
oracle 356 1 0 2020 ? 00:00:00 /bin/sh /home/oracle/
oracle 8315 8241 0 10:11 pts/26 00:00:00 grep --color=auto 356
oracle 23562 1 0 2020 ? 00:00:00 /bin/sh /home/oracle/
oracle@
oracle 431 1 0 2020 ? 00:00:00 /bin/sh /home/oracle/
oracle 4314 1 0 2020 ? 00:00:00 /lib/systemd/
oracle 4315 4314 0 2020 ? 00:00:00 (sd-pam)
oracle 8325 8241 0 10:11 pts/26 00:00:00 grep --color=auto 431
oracle@
oracle 580 1 0 2020 ? 00:00:00 /bin/sh /home/oracle/
oracle 4580 1 0 2020 ? 00:02:25 ora_p005_BDAPX20
oracle 8327 8241 0 10:11 pts/26 00:00:00 grep --color=auto 580
oracle@
oracle@
oracle 356 1 0 2020 ? 00:00:00 /bin/sh /home/oracle/
oracle 8289 8241 0 10:10 pts/26 00:00:00 grep --color=auto 356
oracle 23562 1 0 2020 ? 00:00:00 /bin/sh /home/oracle/
oracle@
oracle 431 1 0 2020 ? 00:00:00 /bin/sh /home/oracle/
oracle 4314 1 0 2020 ? 00:00:00 /lib/systemd/
oracle 4315 4314 0 2020 ? 00:00:00 (sd-pam)
oracle 8292 8241 0 10:10 pts/26 00:00:00 grep --color=auto 431
oracle@
oracle 580 1 0 2020 ? 00:00:00 /bin/sh /home/oracle/
oracle 4580 1 0 2020 ? 00:02:25 ora_p005_BDAPX20
oracle 8295 8241 0 10:10 pts/26 00:00:00 grep --color=auto 580
-------
Revision history for this message
|
#12 |
If the "peaceful" signals SIGHUP and SIGTERM do not work, then try killing the processes with SIGKILL
kill -SIGKILL 356 431 580
Revision history for this message
|
#13 |
Thanks for the update.
even SIGKILL not worked for me. Plz find the details below,
oracle@
oracle@
oracle@
oracle@
oracle 356 1 0 2020 ? 00:00:00 /bin/sh /home/oracle/
Revision history for this message
|
#14 |
What is the output of
which kill
Revision history for this message
|
#15 |
Pleaser find the out below,
root@bd-server1:~# which kill
/bin/kill
root@bd-server1:~#
Revision history for this message
|
#16 |
If the command
sudo /bin/kill -SIGKILL 356
does not work, then I am running out of ideas.
A reboot will most probably help, but I do not know whether this is feasible.
Revision history for this message
|
#17 |
Thankyou "Manfred Hampl".
yes, Will check other alternatives and finally will go with reboot if required. will keep updated this if issue is fixed wthout reboot.
Can you help with this problem?
Provide an answer of your own, or ask Saiprakash Muvva for more information if necessary.