Cron Error /bin/sh Root Command Not Found
Contents |
I struggled with making the crontab work on my system. I am using cron jobs for the first time.Although I always wanted to understand how it works, esp as I heard that they are good cron /bin/sh not found for periodic backups.But it was quite frustrating for me to make it work, cron /bin/bash: root: command not found especially if you prefer to google without reading the man pagesthorougly. Let me just explain what I was trying to bin sh 1 command not found cron achieve and how the error got resolved. Now I realize I could have saved a lot of time, had I read the man pages :( But sometimes we are in a hurry and
Cron Command Not Found
we are not at all interested in understanding how things work, but in making it work as quickly as possible. For those who want a quick look at resolution of this error I would say,check your cron syntax: 1. If you are making changes in a local cron file using crontab -e, the job entry should contain 6 fields (not the username)like this: * * * * /bin/sh: applications: command not found * /home/build_auto/echo.sh A wrong entry like this:* * * * * root /home/build_auto/echo.sh would cause cron to interpret "root" as a command. THe syntax "* * * * * root /home/build_auto/echo.sh" is valid for system crontab file /etc/crontab. Most of the syntax related examples can be found by reading the man page for crontab files: man 5 crontab Creating a simple cron job to run a shell script***************************************************I am simply trying to create a cron job and which would execute a shell script for me at regular intervals.So first I read through a simple tutorial from where I learn about the basic syntax and the fields. Now for my simple cron job, I create a simple shell script which will output some data in another text file.And for simplicity I would like to run it every minute. (so that I can quickly confirm how it works) So here is my simple shell script which will append a string ("test") to another text file (test.txt)echo.sh #!/bin/sh echo "test" >> /home/build_auto/test.txt This way everytime the script echo.sh is executed, it will append a string "test" in a new line in test.txt. So when our cron job executes perfectly i.e. every m
found" From: Ron Leach
2009, 02:36 PMcron is running fine but, i can not seem to find a reason for the emails-- they all say the same /bin/sh: root: not found sh is link to: /bin/sh -> dash this is happing on my other box also- has for yrs lol just https://ubuntuforums.org/archive/index.php/t-1035016.html tired of it thanks in advanced unutbuJanuary 9th, 2009, 02:50 PMIf you type /bin/sh -c root You will get the error message: /bin/sh: root: not found This looks similar to the message you are receiving in the email. This leads me to believe http://www.centos.org/forums/viewtopic.php?t=39747 that you have a crontab entry which is asking cron to run a program named "root". How about type crontab -e and look for a line that begins with the word "root" in the 6th column * * * * * root not found Note that /etc/crontab uses a different format than personal crontabs. In /etc/crontab, the 6th column specifies the user who is supposed to run the command, while in a personal crontab the 6th column specifies the command. If this does not help, type sudo -i crontab -e and look at root's personal crontab. If that does not help, match the timestamp on the email against the timestamps in /var/log/syslog to find the full crontab command that is generating the error message. lift28January 9th, 2009, 03:14 PMthanks command not found for your response my crontab looks as you said cheri@cheri:~$ cat /etc/crontab # /etc/crontab: system-wide crontab # Unlike any other crontab you don't have to run the `crontab' # command to install the new version when you edit this file # and files in /etc/cron.d. These files also have username fields, # that none of the other crontabs do. SHELL=/bin/sh PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin # m h dom mon dow user command 17 * * * * root cd / && run-parts --report /etc/cron.hourly 25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily ) 47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly ) 52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly ) # 20 2 * * * root /etc/network/if-up.d/ntpdate >/dev/null 2>&1 47 3 * * 7 cheri /etc/backup-jobs/cheri-weekly-backup the relating line to the email is: /USR/SBIN/CRON[3039]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly) i check all users crontabs - they are all empty-- the only changes are the last 2 lines i made unutbuJanuary 9th, 2009, 03:55 PMLook inside /etc/cron.hourly. One of the scripts in that directory may be causing the problem. Edit: Although I don't think this is the source of your current problem, note that cron has a funny quirk/bug which requires that each entry in the crontab must end with a newline character. This is the reason that there is an empty comment line
Configuring, Troubleshooting server daemons such as Web and Mail Post Reply Print view Search Advanced search 10 posts • Page 1 of 1 cking Posts: 41 Joined: 2005/05/25 16:01:16 Location: Wichita Kansas cron.hourly Quote Postby cking » 2005/09/07 21:08:28 Noticing my ClamAV has not updated since the 1st of September, I checked the local mail and each time cron.houly is run, the below message is sent./bin/bash: root: command not foundThe only changes I had made with crontab was commenting out a line and adding the exact same line below the commented out line, but changed the run time by about 15 minutes. On the same day, I removed my addition and removed the comment so it would be like normal. Below is what my /etc/crontab looks like:-----SHELL=/bin/bashPATH=/sbin:/bin:/usr/sbin:/usr/binMAILTO=rootHOME=/# run-parts01 * * * * root run-parts /etc/cron.hourly02 4 * * * root run-parts /etc/cron.daily22 4 * * 0 root run-parts /etc/cron.weekly42 4 1 * * root run-parts /etc/cron.monthly# shut down spamassassin after rulesdejour does an update at 4am30 * * * * root /etc/init.d/spamassassin stop-----when run from command line, the process runs without error. There must be something I am not looking at, please help me resolve this issue.Thanks Top K_Frye Posts: 425 Joined: 2005/07/13 01:48:35 Location: Canada Re: cron.hourly Quote Postby K_Frye » 2005/09/08 13:27:59 cking wrote:Noticing my ClamAV has not updated since the 1st of September, I checked the local mail and each time cron.houly is run, the below message is sent./bin/bash: root: command not foundThe only changes I had made with crontab was commenting out a line and adding the exact same line below the commented out line, but changed the run time by about 15 minutes. On the same day, I removed my addition and removed the comment so it would be like normal. Below is what my /etc/crontab looks like:-----SHELL=/bin/bashPATH=/sbin:/bin:/usr/sbin:/usr/binMAILTO=rootHOME=/# run-parts01 * * * * root run-parts /etc/cron.hourly02 4 * * * root run-parts /etc/cron.daily22 4 * * 0 root run-parts /etc/cron.weekly42 4 1 * * root run-parts /etc/cron.monthly# shut down spamassassin after rulesdejour does an update at 4am30 * * * * root /etc/init.d/spamassassin stop-----when run from command line, the process runs without error. There must be something I am not looking at, please help me resolve this issue.ThanksDid you edit /etc/crontab with a text editor or di