Ubuntu Servers :: After Using Crontab With /etc/crontab / Giving Error "can't Find Command Root"?
Aug 26, 2010
I have a question about using crontab with /etc/crontab...
I had a cron job that I needed to run as root. At the time I thought that sticking it in /etc/crontab would be a good idea. However, I used the crontab command to edit /etc/crontab, which I guess is not standard procedure? Specifically, I configured /etc/crontab as my local user's crontab (i.e. sudo crontab /etc/crontab) then added my cron job as I would a local user crontab (i.e. sudo crontab -e).
Originally, my cron job looked like this:
30 * * * * root /my/batch/script &> /dev/null
After adding the new cron job I started seeing errors. Something to the effect of "can't find command root" or something similar. So I removed the 'root' user definition from the cron job and the job started running fine. However, because this is /etc/crontab, there are other system related cron jobs that have been defined to run under the root account (e.g. "17 * * * * root cd / && run-parts --report /etc/cron.hourly" runs as root, etc.). So these pre-existing system cron jobs, which up until now have been running smoothly, are now generating "can't find command root" errors. But I think that the system cron jobs _are_ successfully being run someplace because logrotate seems to be working.
So what I _think_ is happening is that /etc/crontab is being run twice: once as the system crontab, and once as my sudoed local user's crontab. When I run crontab -l I see nothing, but when I run sudo crontab -l I can see the contents of /etc/crontab. I am reluctant to delete my sudoed local user's crontab, because then in the process I would be deleting the system crontab, and I do not know how I should restore the system crontab's contents. (I am still not sure as to the most appropriate way to edit the system crontab).
How can I get out of this mess? I want /etc/crontab to go back to the way it was before--running _once_ as the system crontab. As for my new cron job, I'm willing to reconfigure it anywhere so long as I am still able to run it as root. Any ideas? (I am using Ubuntu 8.04 Server LTE)
I am using Linux 64 bit Redhat Linux. I am trying to setup simple crontab as follow...1. Edited crontab file using crontab -e2. Listed the file once to verify it using crontab -l. This will display as.. 18 5 * * 2-3 ksh $HOME/testScript.sh > $HOME/testscript.out3. Logged in a root and restarted cron deamon using "/etc/init.d/crond restart"As per my understanding now my testScript should start running at 5:18 am Thuesday
I have installed an application manager(monitoring application) on my linux server. Now, i need to have backup schedule for my application. The application itself has executive file to backup database.But when i put this file in my crontab to schedule the backup program it wont run!50 09 * * * root /opt/ME/AppManager9/bin/BackupMysqlDB.sh
I am setting my cron to work. I am in the roo account/ So first I type as vi crontab -e. Then it ask me type "visual" for normal mode and do that then I type the following as below 1 * * * * root usr/local/testClient/runClient.sh>/usr/local/testClient/cron1.log and press esc type wq. Then I restart the cron service /etc/init.d/crond stop and /etc/init.d/crond start. Lastly when I type crontab -l it tells me no crontab for root.
I have set up my crontab and whilst Im logged in and it works (It runs my shell script), however when Im not logged in, the script does not run. Initially I set the time/date to 0 0 * * * (Midnight every day), as this did not work, I tested it with to 0 * * * * (every hour) whilst logged in and the script starts.
I use crontab -e to set it up under the root account..Im sure you dont have to be logged in for it to run?, but maybe im missing a step or just overdosing on Linux and need a holiday:-)
When I setup crontab as a local user (settings shown below), then it can pop-up a xmessage windows * * * * * DISPLAY=:0.0 /usr/bin/xmessage -center "warning message here" but when I switch to root, and setup the same things in crontab, why it cannot pop-up a xmessage windows? Any special limitation for root to use crontab?
I write a little script that run top command and clear the output leaving only cpu ram and swap values. If i run the script manually everityng works fine but when i schedule the cript to run every 5 minutes from /etc/crontab all run fine but the output of the top command doesnt appear in the log :
I have been having trouble setting up a daily backup script with cron. It would basically never worked. Searched the net for answers but didn't find anything. I finally figured it out !! When root crontab is edited the execute flag is removed from #/var/spool/cron/crontabs/root. I change it with #chmod a+x /var/spool/cron/crontabs/root and all is good.
I've just discovered that crontab is creating a new file in the root directory every time it executes a cronjob, and it doesn't erase over the old file so there are thousands of files in the root directory, they have the same name as the script file (appended with a numeral) but are all blank.here is what one of the cronjob's looks like[URL]
when a script in /etc/cron.d directory will be executed?. I know that scripts in cron.daily will be executed daily [ set in /etc/crontab file]? Cant able to find this directory listed in /etc/crontab file?
How to break strings of command into multi-lines in crontab? e.g. Code: # the following is a very long a gruesome command to be run at 09:59 Monday to Friday. 59 09 * * 1-5 source $HOME/some-definitions; sh /usr/local/my/long/name/application/bin/hello $(date +\%Y\%m\%d) >>/var/log/my/long/name/application/log/hello.log
I have install RHEL5 and created normal user as "test". When I login as root user, I can run crontab command but when I login as test user, I can't run crontab command and throws error as "cron/test: Permission denied". how to enable crontab command for test user as well?
Having an odd problem running a mysqldump via crontab. I have the script running on other servers and they work fine, so not sure how to actually troubleshoot, but the script looks like the following;
If I run it as a cronjob as root, it finishes in a second and a 20k file is there. If I run it from the command line as root it does the backup (takes a few minutes) but does complete the backup and can be unzipped and read successfully.
Either no error and it doesn't run (The scripts all run fine manually and in the cron.daily, cron.hourly, etc. directories.) If it does try to run it, it shows this: Feb 16 12:59:01 buddha crond: (*system*) BAD FILE MODE (/etc/crontab). Here's my crontab:
How to set crontab not send mail notification to the owner script if the script success running? because I'm monitoring mail server, and notification from cron is not necessary for me. I'm using ubuntu 10.04 server