CentOS7 crontab is not executed. Error/bin/sh: root: command not found, centos7crontab

Source: Internet
Author: User

CentOS7 crontab is not executed. Error/bin/sh: root: command not found, centos7crontab

When you use CentOS7 to execute the scheduled script, an error is returned:

/bin/sh: root: command not found


The problem is that the file/var/spool/cron/root does not need to be written as root.

The modified script:

[root@localhost cron]# crontab -l*/10 * * * * perl /home/awstats/wwwroot/cgi-bin/awstats.pl -update -config=www.zbphp.com >> /sbin/null 2>&1



File/etc/crontab:

[root@localhost ~]# nano /etc/crontabSHELL=/bin/bashPATH=/sbin:/bin:/usr/sbin:/usr/binMAILTO=root# For details see man 4 crontabs# Example of job definition:# .---------------- minute (0 - 59)# |  .------------- hour (0 - 23)# |  |  .---------- day of month (1 - 31)# |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...# |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat# |  |  |  |  |# *  *  *  *  * user-name  command to be executed

View crontab status:

[root@localhost logs]# service crond statusRedirecting to /bin/systemctl status  crond.servicecrond.service - Command Scheduler   Loaded: loaded (/usr/lib/systemd/system/crond.service; enabled)   Active: active (running) since Sat 2014-10-18 19:13:38 HKT; 31min ago Main PID: 17467 (crond)   CGroup: /system.slice/crond.service           └─17467 /usr/sbin/crond -nOct 18 19:13:38 localhost.localdomain crond[17467]: (CRON) INFO (RANDOM_DELAY will be scaled with factor 56% if used.)Oct 18 19:13:38 localhost.localdomain crond[17467]: (CRON) INFO (running with inotify support)Oct 18 19:13:38 localhost.localdomain crond[17467]: (CRON) INFO (@reboot jobs will be run at computer's startup.)Oct 18 19:24:01 localhost.localdomain crond[17467]: (*system*) RELOAD (/etc/crontab)Oct 18 19:27:01 localhost.localdomain crond[17467]: (root) RELOAD (/var/spool/cron/root)Oct 18 19:32:01 localhost.localdomain crond[17467]: (root) RELOAD (/var/spool/cron/root)Oct 18 19:33:01 localhost.localdomain crond[17467]: (root) RELOAD (/var/spool/cron/root)Oct 18 19:34:01 localhost.localdomain crond[17467]: (root) RELOAD (/var/spool/cron/root)Oct 18 19:38:01 localhost.localdomain crond[17467]: (root) RELOAD (/var/spool/cron/root)Oct 18 19:40:01 localhost.localdomain crond[17467]: (root) RELOAD (/var/spool/cron/root)


By default7 # zbphp.com



Shell script is not executed in the scheduled task. The simple SH is used to compress the crontab of the log yesterday. It is defined to be executed at half past four every day, but it is not executed.

See where bzip2 is in the system, for example, in/usr/bin.

Replace bzip2-9 *. log

Cd/data/$ {y}/$ {m}/$ {d}

/Usr/bin/bzip2-9 *. log

Try it.

Crontab is not executed. The prompt is not found?

Reply to wenhq permission 644, owner ok988.ok988. I was wondering if the cron execution was not performed as the current user, but with other users (such as daemon and other low-privilege execution ), in this case,/home/ok988 does not have the rx permission at all. The home Directory has the 700 permission, and other users cannot enter the home directory, so the prompt not found ?? So permission denied ?? View Original post>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.