linux 系统查看所有用户的crontab定时任务

linux 系统查看所有用户的crontab任务

方法一:查看某个用户的crontab任务

crontab -l -u username

下面是root用户和magento用户

[magento@ip-172-31-2-29 mage-tags]$ crontab -l -u root
must be privileged to use -u
#必须使用root用户进行操作查看
[magento@ip-172-31-2-29 mage-tags]$ su root
Password: 
[root@ip-172-31-2-29 mage-tags]# crontab -l -u root

crontab -l -u root


[root@ip-172-31-2-29 mage-tags]# crontab -l -u magento

#~ MAGENTO START c9d202cf0efd5d1947c9b46c016fb91e40b3bf526e5b736864bf54b8cc479673
* * * * * /usr/bin/php /usr/share/nginx/html/keyssggffan.com/m2-new/bin/magento cron:run 2>&1 | grep -v "Ran jobs by schedule" >> /usr/share/nginx/html/keyssggffan.com/m2-new/var/log/magento.cron.log
#~ MAGENTO END c9d202cf0efd5d1947c9b46c016fb91e40b3bf526e5b736864bf54b8cc479673
#~ MAGENTO START 34dc4fd4a11b0fee8a7044c08cf1ea0463d381db90655c8f4b0223833ea86559
* * * * * /usr/bin/php /usr/share/nginx/html/mgt245/m2-new/bin/magento cron:run 2>&1 | grep -v "Ran jobs by schedule" >> /usr/share/nginx/html/mgt245/m2-new/var/log/magento.cron.log
#~ MAGENTO END 34dc4fd4a11b0fee8a7044c08cf1ea0463d381db90655c8f4b0223833ea86559

方法二:查看所有用户的crontab任务

cat /etc/passwd | cut -f 1 -d : |xargs -I {} crontab -l -u {}
#执行效果如下:
[root@ip-172-31-2-29 mage-tags]# cat /etc/passwd | cut -f 1 -d : |xargs -I {} crontab -l -u {}


no crontab for bin
no crontab for daemon
no crontab for adm
no crontab for lp
no crontab for sync
no crontab for shutdown
no crontab for halt
no crontab for mail
no crontab for operator
no crontab for games
no crontab for ftp
no crontab for nobody
no crontab for systemd-network
no crontab for dbus
no crontab for rpc
no crontab for libstoragemgmt
no crontab for sshd
no crontab for rpcuser
no crontab for nfsnobody
no crontab for rngd
no crontab for ec2-instance-connect
no crontab for postfix
no crontab for chrony
no crontab for tcpdump
no crontab for ec2-user
no crontab for nginx
no crontab for apache
no crontab for ben
no crontab for mysql

#~ MAGENTO START c9d202cf0efd5d1947c9b46c016fb91e40b3bf526e5b736864bf54b8cc479673
* * * * * /usr/bin/php /usr/share/nginx/html/keysfan.com/m2-new/bin/magento cron:run 2>&1 | grep -v "Ran jobs by schedule" >> /usr/share/nginx/html/keysfan.com/m2-new/var/log/magento.cron.log
#~ MAGENTO END c9d202cf0efd5d1947c9b46c016fb91e40b3bf526e5b736864bf54b8cc479673
#~ MAGENTO START 34dc4fd4a11b0fee8a7044c08cf1ea0463d381db90655c8f4b0223833ea86559
* * * * * /usr/bin/php /usr/share/nginx/html/mgt245/m2-new/bin/magento cron:run 2>&1 | grep -v "Ran jobs by schedule" >> /usr/share/nginx/html/mgt245/m2-new/var/log/magento.cron.log
#~ MAGENTO END 34dc4fd4a11b0fee8a7044c08cf1ea0463d381db90655c8f4b0223833ea86559

no crontab for peter
no crontab for elasticsearch

方法三:查看用户的crontab任务

该目录下存放着所有用户的crontab任务

/var/spool/cron/   
cd /var/spool/cron/
[root@ip-172-31-2-29 cron]# ls -al
total 8
drwx------ 2 root    root   33 Nov  3 07:38 
.
drwxr-xr-x 9 root    root   97 Jun 13  2022 ..
-rw------- 1 magento nginx 700 Nov  3 07:38 magento
-rw------- 1 root    root    2 Oct 31 06:24 root

[root@ip-172-31-2-29 cron]# 
查看定时任务

Leave a comment

您的电子邮箱地址不会被公开。 必填项已用 * 标注