热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

机器重启查看crontab执行历史记录crontab没有执行

Sep1719:01:01drun-parts(etccron.hourly)[8452]:finished0anacronSep1719:10:01dCROND[

 

 


Sep 17 19:01:01 d run-parts(/etc/cron.hourly)[8452]: finished 0anacron
Sep 17 19:10:01 d CROND[9059]: (root) CMD (cd /root/tools/trunk/plugins/personas; python sync_db.py &> /dev/null)
Sep 17 19:10:01 d CROND[9060]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Sep 17 19:20:01 d CROND[9736]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Sep 17 19:20:01 d CROND[9737]: (root) CMD (cd /root/tools/trunk/plugins/personas; python sync_db.py &> /dev/null)
Sep 17 19:30:01 d CROND[10411]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Sep 17 19:30:01 d CROND[10412]: (root) CMD (cd /root/tools/trunk/plugins/personas; python sync_db.py &> /dev/null)
Sep 17 19:32:10 d crontab[10571]: (root) LIST (root)
Sep 17 19:40:01 d CROND[11086]: (root) CMD (cd /root/tools/trunk/plugins/personas; python sync_db.py &> /dev/null)
Sep 17 19:40:01 d CROND[11087]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Sep 17 19:50:01 d CROND[11762]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Sep 17 19:50:01 d CROND[11763]: (root) CMD (cd /root/tools/trunk/plugins/personas; python sync_db.py &> /dev/null)
Sep 20 12:40:02 d crontab[582]: (root) LIST (root)
Sep 20 13:36:43 d crontab[4633]: (root) LIST (root)
Sep 20 14:46:11 d crontab[9954]: (root) LIST (root)
[root@d log]# tail -100 /var/log/cron

 

 

CentOS下查看crontab执行历史记录 - Jerry.Kwan - 博客园 https://www.cnblogs.com/Jerryshome/archive/2012/02/16/2353537.html

在crontab中添加了定时任务,但发现没有得到期望的结果,因而怀疑是crontab没有执行相应的任务,但怎么定位crontab是否执行呢?
这就需要查看crontab的执行历史记录,具体位置如下:
cd /var/log
tail -100 cron
在cron文件中即可查阅已经操作过的相关定时任务。

 

查看定时脚本目录

[root@d log]# ll -as /var/spool/
total 52
4 drwxr-xr-x. 13 root root 4096 Sep 14 23:24 .
4 drwxr-xr-x. 23 root root 4096 Sep 14 23:23 ..
4 drwxr-x--x 2 root abrt 4096 Apr 27 22:53 abrt
4 drwx------. 2 abrt abrt 4096 Apr 27 22:53 abrt-upload
4 drwxr-xr-x. 2 root root 4096 Apr 11 09:48 anacron
4 drwx------. 3 root root 4096 Apr 11 08:13 at
4 drwx------. 2 root root 4096 Apr 11 09:48 cron
4 drwx--x---. 3 root lp 4096 Apr 11 13:03 cups
4 drwxr-xr-x. 2 root root 4096 Apr 11 12:59 lpd
4 drwxrwxr-x. 2 root mail 4096 Apr 11 12:59 mail
4 drwxr-xr-x. 2 root root 4096 Apr 13 20:53 plymouth
4 drwxr-xr-x. 16 root root 4096 Nov 21 2014 postfix
4 drwxrwxrwt 2 root root 4096 Jan 18 2017 samba
[root@d log]# ll -as /var/spool/cron/
total 12
4 drwx------. 2 root root 4096 Apr 11 09:48 .
4 drwxr-xr-x. 13 root root 4096 Sep 14 23:24 ..
4 -rw------- 1 root root 398 Jun 7 09:05 root
[root@d log]# cat /var/spool/cron/root
# create by root at 2017/10/20
*/10 * * * * cd /root/tools/trunk/plugins/personas; python sync_db.py &> /dev/null

# create by root at 2017/10/27
00 02 * * * cd /root/tools/trunk/plugins/personas; python sync_db_full.py &> /dev/null


[root@d log]#

 

 

 

 


[root@d log]# systemctl list-unit-files --type=service > tmpDEL
[root@d log]# cat tmpDEL
UNIT FILE STATE
abrt-ccpp.service disabled
abrt-oops.service disabled
abrt-pstoreoops.service disabled
abrt-vmcore.service disabled
abrt-xorg.service disabled
abrtd.service disabled
aliyun.service disabled
arp-ethers.service disabled
atd.service disabled
auditd.service disabled
auth-rpcgss-module.service static
autovt@.service enabled
avahi-daemon.service disabled
blk-availability.service disabled
brandbot.service static
chrony-wait.service disabled
chronyd.service disabled
console-getty.service disabled
console-shell.service disabled
container-getty@.service static
cpupower.service disabled
crond.service enabled
cups-browsed.service disabled
cups.service enabled
dbus-org.freedesktop.hostname1.service static
dbus-org.freedesktop.import1.service static
dbus-org.freedesktop.locale1.service static
dbus-org.freedesktop.login1.service static
dbus-org.freedesktop.machine1.service static
dbus-org.freedesktop.timedate1.service static
dbus.service static
debug-shell.service disabled
dm-event.service static
dmraid-activation.service enabled
dnsmasq.service disabled
dracut-cmdline.service static
dracut-initqueue.service static
dracut-mount.service static
dracut-pre-mount.service static
dracut-pre-pivot.service static
dracut-pre-trigger.service static
dracut-pre-udev.service static
dracut-shutdown.service static
ebtables.service disabled
emergency.service static
firewalld.service disabled
fprintd.service static
fstrim.service static
getty@.service enabled
gssproxy.service disabled
halt-local.service static
initrd-cleanup.service static
initrd-parse-etc.service static
initrd-switch-root.service static
initrd-udevadm-cleanup-db.service static
irqbalance.service disabled
kdump.service disabled
kmod-static-nodes.service static
libstoragemgmt.service disabled
lvm2-lvmetad.service disabled
lvm2-lvmpolld.service disabled
lvm2-monitor.service enabled
lvm2-pvscan@.service static
mdmon@.service static
mdmonitor.service disabled
messagebus.service static
microcode.service enabled
NetworkManager-dispatcher.service disabled
NetworkManager-wait-online.service enabled
NetworkManager.service disabled
nfs-blkmap.service disabled
nfs-config.service static
nfs-idmap.service static
nfs-idmapd.service static
nfs-lock.service static
nfs-mountd.service static
nfs-rquotad.service disabled
nfs-secure.service static
nfs-server.service disabled
nfs-utils.service static
nfs.service disabled
nfslock.service static
nmb.service disabled
nscd.service enabled
ntpd.service enabled
ntpdate.service disabled
plymouth-halt.service disabled
plymouth-kexec.service disabled
plymouth-poweroff.service disabled
plymouth-quit-wait.service disabled
plymouth-quit.service disabled
plymouth-read-write.service disabled
plymouth-reboot.service disabled
plymouth-start.service disabled
plymouth-switch-root.service static
polkit.service static
postfix.service disabled
psacct.service disabled
quotaon.service static
rc-local.service static
rdisc.service disabled
rdma-load-modules@.service static
rdma-ndd.service static
rdma.service disabled
redis-sentinel.service disabled
redis.service disabled
rescue.service static
rhel-autorelabel-mark.service enabled
rhel-autorelabel.service enabled
rhel-configure.service enabled
rhel-dmesg.service enabled
rhel-domainname.service enabled
rhel-import-state.service enabled
rhel-loadmodules.service enabled
rhel-readonly.service enabled
rngd.service disabled
rpc-gssd.service static
rpc-rquotad.service disabled
rpc-statd-notify.service static
rpc-statd.service static
rpcbind.service disabled
rpcgssd.service static
rpcidmapd.service static
rsyncd.service disabled
rsyncd@.service static
rsyslog.service enabled
serial-getty@.service disabled
smartd.service disabled
smb.service disabled
sshd-keygen.service static
sshd.service enabled
sshd@.service static
svnserve.service disabled
sysstat.service enabled
systemd-ask-password-console.service static
systemd-ask-password-plymouth.service static
systemd-ask-password-wall.service static
systemd-backlight@.service static
systemd-binfmt.service static
systemd-bootchart.service disabled
systemd-firstboot.service static
systemd-fsck-root.service static
systemd-fsck@.service static
systemd-halt.service static
systemd-hibernate-resume@.service static
systemd-hibernate.service static
systemd-hostnamed.service static
systemd-hwdb-update.service static
systemd-hybrid-sleep.service static
systemd-importd.service static
systemd-initctl.service static
systemd-journal-catalog-update.service static
systemd-journal-flush.service static
systemd-journald.service static
systemd-kexec.service static
systemd-localed.service static
systemd-logind.service static
systemd-machine-id-commit.service static
systemd-machined.service static
systemd-modules-load.service static
systemd-nspawn@.service disabled
systemd-poweroff.service static
systemd-quotacheck.service static
systemd-random-seed.service static
systemd-readahead-collect.service enabled
systemd-readahead-done.service indirect
systemd-readahead-drop.service enabled
systemd-readahead-replay.service enabled
systemd-reboot.service static
systemd-remount-fs.service static
systemd-rfkill@.service static
systemd-shutdownd.service static
systemd-suspend.service static
systemd-sysctl.service static
systemd-timedated.service static
systemd-tmpfiles-clean.service static
systemd-tmpfiles-setup-dev.service static
systemd-tmpfiles-setup.service static
systemd-udev-settle.service static
systemd-udev-trigger.service static
systemd-udevd.service static
systemd-update-done.service static
systemd-update-utmp-runlevel.service static
systemd-update-utmp.service static
systemd-user-sessions.service static
systemd-vconsole-setup.service static
tcsd.service disabled
teamd@.service static
tuned.service disabled
usb_modeswitch@.service static
wpa_supplicant.service disabled

191 unit files listed.

【开机启动 != 启动成功】

[root@d log]# service crond status
Redirecting to /bin/systemctl status crond.service
● crond.service - Command Scheduler
Loaded: loaded (/usr/lib/systemd/system/crond.service; enabled; vendor preset: enabled)
Active: failed (Result: signal) since Mon 2018-09-17 19:55:43 CST; 2 days ago
Main PID: 562 (code=killed, signal=KILL)

Sep 17 19:30:01 d crond[10409]: pam_limits(crond:session): invalid line 'soft nofile 95535' - skipped
Sep 17 19:30:01 d crond[10409]: pam_limits(crond:session): invalid line 'hard nofile 95535' - skipped
Sep 17 19:40:01 d crond[11085]: pam_limits(crond:session): invalid line 'soft nofile 95535' - skipped
Sep 17 19:40:01 d crond[11085]: pam_limits(crond:session): invalid line 'hard nofile 95535' - skipped
Sep 17 19:40:01 d crond[11084]: pam_limits(crond:session): invalid line 'soft nofile 95535' - skipped
Sep 17 19:40:01 d crond[11084]: pam_limits(crond:session): invalid line 'hard nofile 95535' - skipped
Sep 17 19:50:01 d crond[11760]: pam_limits(crond:session): invalid line 'soft nofile 95535' - skipped
Sep 17 19:50:01 d crond[11760]: pam_limits(crond:session): invalid line 'hard nofile 95535' - skipped
Sep 17 19:50:01 d crond[11761]: pam_limits(crond:session): invalid line 'soft nofile 95535' - skipped
Sep 17 19:50:01 d crond[11761]: pam_limits(crond:session): invalid line 'hard nofile 95535' - skipped
[root@d log]#

 

 

原因为最大文件数配置错误

/etc/security/limits.conf

启动crond和检测状态

[root@d ~]# service crond status -l
Redirecting to /bin/systemctl status -l crond.service
● crond.service - Command Scheduler
Loaded: loaded (/usr/lib/systemd/system/crond.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Thu 2018-09-20 15:43:30 CST; 2min 14s ago
Process: 14736 ExecStart=/usr/sbin/crond -n $CRONDARGS (code=exited, status=1/FAILURE)
Main PID: 14736 (code=exited, status=1/FAILURE)

Sep 20 15:43:30 d systemd[1]: Started Command Scheduler.
Sep 20 15:43:30 d systemd[1]: Starting Command Scheduler...
Sep 20 15:43:30 d crond[14736]: crond: can't lock /var/run/crond.pid, otherpid may be 12554: Resource temporarily unavailable
Sep 20 15:43:30 d systemd[1]: crond.service: main process exited, code=exited, status=1/FAILURE
Sep 20 15:43:30 d systemd[1]: Unit crond.service entered failed state.
Sep 20 15:43:30 d systemd[1]: crond.service failed.
[root@d ~]# service crond start
Redirecting to /bin/systemctl start crond.service
[root@d ~]# service crond status -l
Redirecting to /bin/systemctl status -l crond.service
● crond.service - Command Scheduler
Loaded: loaded (/usr/lib/systemd/system/crond.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2018-09-20 15:46:01 CST; 7s ago
Main PID: 15049 (crond)
CGroup: /system.slice/crond.service
└─15049 /usr/sbin/crond -n

Sep 20 15:46:01 d systemd[1]: Started Command Scheduler.
Sep 20 15:46:01 d systemd[1]: Starting Command Scheduler...
Sep 20 15:46:01 d crond[15049]: (CRON) INFO (RANDOM_DELAY will be scaled with factor 80% if used.)
Sep 20 15:46:01 d crond[15049]: (CRON) INFO (running with inotify support)
Sep 20 15:46:01 d crond[15049]: (CRON) INFO (@reboot jobs will be run at computer's startup.)
[root@d ~]#

 


推荐阅读
  • 微软头条实习生分享深度学习自学指南
    本文介绍了一位微软头条实习生自学深度学习的经验分享,包括学习资源推荐、重要基础知识的学习要点等。作者强调了学好Python和数学基础的重要性,并提供了一些建议。 ... [详细]
  • Centos7.6安装Gitlab教程及注意事项
    本文介绍了在Centos7.6系统下安装Gitlab的详细教程,并提供了一些注意事项。教程包括查看系统版本、安装必要的软件包、配置防火墙等步骤。同时,还强调了使用阿里云服务器时的特殊配置需求,以及建议至少4GB的可用RAM来运行GitLab。 ... [详细]
  • Windows下配置PHP5.6的方法及注意事项
    本文介绍了在Windows系统下配置PHP5.6的步骤及注意事项,包括下载PHP5.6、解压并配置IIS、添加模块映射、测试等。同时提供了一些常见问题的解决方法,如下载缺失的msvcr110.dll文件等。通过本文的指导,读者可以轻松地在Windows系统下配置PHP5.6,并解决一些常见的配置问题。 ... [详细]
  • baresip android编译、运行教程1语音通话
    本文介绍了如何在安卓平台上编译和运行baresip android,包括下载相关的sdk和ndk,修改ndk路径和输出目录,以及创建一个c++的安卓工程并将目录考到cpp下。详细步骤可参考给出的链接和文档。 ... [详细]
  • Linux如何安装Mongodb的详细步骤和注意事项
    本文介绍了Linux如何安装Mongodb的详细步骤和注意事项,同时介绍了Mongodb的特点和优势。Mongodb是一个开源的数据库,适用于各种规模的企业和各类应用程序。它具有灵活的数据模式和高性能的数据读写操作,能够提高企业的敏捷性和可扩展性。文章还提供了Mongodb的下载安装包地址。 ... [详细]
  • Iamtryingtomakeaclassthatwillreadatextfileofnamesintoanarray,thenreturnthatarra ... [详细]
  • 这是原文链接:sendingformdata许多情况下,我们使用表单发送数据到服务器。服务器处理数据并返回响应给用户。这看起来很简单,但是 ... [详细]
  • 如何去除Win7快捷方式的箭头
    本文介绍了如何去除Win7快捷方式的箭头的方法,通过生成一个透明的ico图标并将其命名为Empty.ico,将图标复制到windows目录下,并导入注册表,即可去除箭头。这样做可以改善默认快捷方式的外观,提升桌面整洁度。 ... [详细]
  • 本文介绍了数据库的存储结构及其重要性,强调了关系数据库范例中将逻辑存储与物理存储分开的必要性。通过逻辑结构和物理结构的分离,可以实现对物理存储的重新组织和数据库的迁移,而应用程序不会察觉到任何更改。文章还展示了Oracle数据库的逻辑结构和物理结构,并介绍了表空间的概念和作用。 ... [详细]
  • 个人学习使用:谨慎参考1Client类importcom.thoughtworks.gauge.Step;importcom.thoughtworks.gauge.T ... [详细]
  • CentOS 6.5安装VMware Tools及共享文件夹显示问题解决方法
    本文介绍了在CentOS 6.5上安装VMware Tools及解决共享文件夹显示问题的方法。包括清空CD/DVD使用的ISO镜像文件、创建挂载目录、改变光驱设备的读写权限等步骤。最后给出了拷贝解压VMware Tools的操作。 ... [详细]
  • 本文介绍了将mysql从5.6.15升级到5.7.15的详细步骤,包括关闭访问、备份旧库、备份权限、配置文件备份、关闭旧数据库、安装二进制、替换配置文件以及启动新数据库等操作。 ... [详细]
  • 本文介绍了在CentOS上安装Python2.7.2的详细步骤,包括下载、解压、编译和安装等操作。同时提供了一些注意事项,以及测试安装是否成功的方法。 ... [详细]
  • CEPH LIO iSCSI Gateway及其使用参考文档
    本文介绍了CEPH LIO iSCSI Gateway以及使用该网关的参考文档,包括Ceph Block Device、CEPH ISCSI GATEWAY、USING AN ISCSI GATEWAY等。同时提供了多个参考链接,详细介绍了CEPH LIO iSCSI Gateway的配置和使用方法。 ... [详细]
  • 本文介绍了在Linux系统中设置文件ACL权限的方法和使用说明,包括在centos7.3和centos6.9中开启ACL权限的两种方法:在挂载时指定打开ACL权限和修改默认的属性信息。同时提供了对ACL权限的详细解释和应用场景。 ... [详细]
author-avatar
zg18156zg你
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有