我的脚本被报告为在 CRON 日志中执行,但它没有在任何用户的 crontab 中列出

我的脚本被报告为在 CRON 日志中执行,但它没有在任何用户的 crontab 中列出

这是克朗日志运行一些脚本的计算机(面向互联网连接):

luis@Fostrot:~$ sudo tail -n 50 /var/log/syslog | grep "cron" -i
Jan 19 21:30:01 Fostrot /USR/SBIN/CRON[11014]: (root) CMD (/bin/bash --login -i -c Reconectador3G.sh)
Jan 19 21:30:01 Fostrot /USR/SBIN/CRON[11013]: (root) CMD (/bin/bash --login -i -c ReportarIP.sh)
Jan 19 21:30:01 Fostrot /USR/SBIN/CRON[11015]: (root) CMD (   /bin/ReconectadorVPN.sh)
Jan 19 21:35:01 Fostrot /USR/SBIN/CRON[11224]: (root) CMD (/bin/bash --login -i -c Reconectador3G.sh)
Jan 19 21:35:01 Fostrot /USR/SBIN/CRON[11227]: (root) CMD (/bin/bash --login -i -c ReportarIP.sh)
Jan 19 21:35:01 Fostrot /USR/SBIN/CRON[11225]: (root) CMD (   /bin/ReconectadorVPN.sh)
Jan 19 21:39:01 Fostrot /USR/SBIN/CRON[11452]: (root) CMD (  [ -x /usr/lib/php5/maxlifetime ] && [ -x /usr/lib/php5/sessionclean ] && [ -d /var/lib/php5 ] && /usr/lib/php5/sessionclean /var/lib/php5 $(/usr/lib/php5/maxlifetime))
Jan 19 21:40:01 Fostrot /USR/SBIN/CRON[11477]: (root) CMD (   /bin/ReconectadorVPN.sh)
Jan 19 21:40:01 Fostrot /USR/SBIN/CRON[11478]: (root) CMD (/bin/bash --login -i -c Reconectador3G.sh)
Jan 19 21:40:01 Fostrot /USR/SBIN/CRON[11481]: (root) CMD (/bin/bash --login -i -c ReportarIP.sh)
Jan 19 21:45:01 Fostrot /USR/SBIN/CRON[11832]: (root) CMD (/bin/bash --login -i -c ReportarIP.sh)
Jan 19 21:45:01 Fostrot /USR/SBIN/CRON[11831]: (root) CMD (   /bin/ReconectadorVPN.sh)
Jan 19 21:45:01 Fostrot /USR/SBIN/CRON[11833]: (root) CMD (/bin/bash --login -i -c Reconectador3G.sh)

这是 crontab sudo

luis@Fostrot:~$ sudo crontab -l
# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h  dom mon dow   command
*/5 * * * * /bin/bash --login -i -c Reconectador3G.sh
*/5 * * * * /bin/bash --login -i -c ReportarIP.sh

正如你所看到的,有禁止驶入为了ReconectadorVPN.sh。其他用户没有 crontab,或者看起来是这样:

luis@Fostrot:~$ crontab -l
no crontab for luis

我什至检查了所有用户的 crontab:

root@Fostrot:/home/luis# awk -F: '{print $1}' /etc/passwd | xargs -l1 crontab -lu
# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h  dom mon dow   command
*/5 * * * * /bin/bash --login -i -c Reconectador3G.sh
*/5 * * * * /bin/bash --login -i -c ReportarIP.sh
no crontab for daemon
no crontab for bin
no crontab for sys
no crontab for sync
no crontab for games
no crontab for man
no crontab for lp
no crontab for mail
no crontab for news
no crontab for uucp
no crontab for proxy
no crontab for www-data
no crontab for backup
no crontab for list
no crontab for irc
no crontab for gnats
no crontab for nobody
no crontab for libuuid
no crontab for mysql
no crontab for messagebus
no crontab for colord
no crontab for usbmux
no crontab for miredo
no crontab for ntp
no crontab for Debian-exim
no crontab for avahi
no crontab for beef-xss
no crontab for dradis
no crontab for pulse
no crontab for speech-dispatcher
no crontab for haldaemon
no crontab for iodine
no crontab for postgres
no crontab for sshd
no crontab for snmp
no crontab for stunnel4
no crontab for statd
no crontab for sslh
no crontab for Debian-gdm
no crontab for rtkit
no crontab for saned
no crontab for manolo
no crontab for luis
no crontab for dnsmasq
no crontab for arpwatch
no crontab for redsocks

...而且他们都没有ReconectadorVPN.sh脚本的条目。

这里发生了什么事,我该怎么办定位呼叫ReconectadorVPN.sh脚本?

答案1

从 cron 手册页:

   Cron  searches  /var/spool/cron for crontab files which are named after
   accounts in crontabs found are loaded into memory.  Cron also  searches
   for /etc/crontab and the files in the directory, which are in a differ-
   ent format (see crontab(5) ).

您已经查看了用户 crontabs,但我认为您没有检查过/etc/crontab.它通常包含从多个 cron 目录运行内容的条目。

答案2

这些天您需要在几个地方查找 crontab:

  1. 当然,个人用户的 crontab 通常驻留在 /var/spool/cron/ 中,其中包括用户 root 以及其他用户的 crontab。

  2. /etc/crontab 中有一个仅限根用户的 crontab。据我所知,它包含对运行部分目录的引用,每个任务的文件都位于该目录中。它们通常位于 /etc/cron.daily /etc/cron.hourly /etc/cron.monthly 中。

  3. 现在可以找到 crontab 的另一个区域是在目录 /etc/cron.d/ 下,据我所知,这几天似乎变得更受欢迎。这些区域中的文件通常用于根级别执行。

相关内容