Crontab prompts commandnotfound solution

Source: Internet
Author: User
Recently, crontab is used to execute some commands: regularly synchronize system time with hardware time. Because I always find that the time on my linux server will slow down, and I finally want to synchronize this method. At the beginning, I wrote the command: */1 ***** roothwclock -- hctosys to/ro...
Recently, crontab is used to execute some commands: regularly synchronize system time with hardware time. Because I always find that the time on my linux server will slow down, and I finally want to synchronize this method. At the beginning, I run the following command: */1 ***** root hwclock -- hctosys writes to the/root/spool/cron/root file (you can directly press the Command crontab-u root-e to edit it ), but after the execution, the root user always receives an email about cron with the error message: From root@localhost.localdomain Wed Sep 22 10:10:01 2010Return-Path: Received: from localhost. localdomain (localhost. localdomain [127.0.0.1]) by localhost. localdomain (8.13.8/8.13.8) with ESMTP id o8M2A1bL024533for ; Wed, 22 Sep 2010 10:10:01 + 0800 Received: (from root @ localhost) by localhost. localdomain (8.13.8/8.13.8/Submit) id o8M2A1hh024532; Wed, 22 Sep 2010 10:10:01 + 0800 Date: Wed, 22 Sep 2010 10:10:01 + 0800Message-Id: <201009220210.o8M2A1hh024532@localhost.localdomain> From: root@localhost.localdomain (Cron Daemon) root@localhost.localdomainSubject: Cron Root hwclock -- hctosysContent-Type: text/plain; charset = UTF-8Auto-Submitted: auto-generatedX-Cron-Env: X-Cron-Env: X-Cron-Env: X-Cron-Env: X-Cron-Env: /Bin/sh: root: command not found/bin/sh: root: command not found indicates that the default shell used by crontab is/bin/sh, and the default environment variable of crontab is listed above: X-Cron-Env: // ShellX-Cron-Env used by default: // User directory X-Cron-Env: // Command to search for path X-Cron-Env: // Login username X-Cron-Env: // Solution 1: Add SHELL =/bin/shPATH =/sbin:/bin:/usr/sbin to the root crontab file: /usr/bin solution 2 (this is my choice): write to the/etc/crontab file. in the last line, assume the following code: */1 * root hwclock -- hctosys indicates that the command is executed every 1 minute.
Author ZHB_McCoy

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.