Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Dear all,
After moving to Centos 6, I'm detecting that my crontab is not running any way. I have copied the cron file from my old centos 5, and it's having the following:
When i try to run any of these commands in shel, they are working properly, but when I try to do ./crontab, I get, i.e:
Quote:
./crontab: line 35: 0: command not found
...etc
What's going on? I'm googling into this, but all what i found is relating to install the cronie-anacron, which I already have, and up to date, and else, but nothing is working with me...
Although you didn't specify full path for your programs to get it running, you should:
- check whether your #a2billing and php are in your path (PATH=/sbin:/bin:/usr/sbin:/usr/bin)
- set full pathnames for running programs/scripts, like:
Code:
service crond status
crond (pid 4047) is running...
which php
/usr/bin/php
0 6 * * * /usr/local/a2billing /usr/bin/php /usr/src/Star2Billing/Cronjobs/a2billing_batch_billing.php <-- define your paths according to your system
I'm giving this examples based on CentOS 5.x system, so it should be the same on yours.
service crond status
crond (pid 4871) is running...
Then the perl and the php are properly there as:
Quote:
which php
/usr/bin/php
which perl
/usr/bin/perl
But the users, root, it's the root itself, so the first lines should have no problem to get executed, as root, but it's showing also as command not found into:
Quote:
17 * * * * root run-parts /etc/cron.hourly
I have changed the command, instead of username, to user-path.. as you suggest, but it's showing:
Quote:
./crontab
./crontab: línea 19: 17: no se encontró la orden
./crontab: línea 20: 38: no se encontró la orden
./crontab: línea 21: 11: no se encontró la orden
./crontab: línea 22: 13: no se encontró la orden
./crontab: línea 23: 0: no se encontró la orden
./crontab: línea 24: 0: no se encontró la orden
./crontab: línea 25: 0: no se encontró la orden
./crontab: línea 28: 0: no se encontró la orden
./crontab: línea 29: 0: no se encontró la orden
./crontab: línea 30: 0: no se encontró la orden
./crontab: línea 31: 20: no se encontró la orden
./crontab: línea 32: 0: no se encontró la orden
./crontab: línea 33: 0: no se encontró la orden
./crontab: línea 34: 1: no se encontró la orden
./crontab: línea 35: 0: no se encontró la orden
./crontab: línea 36: 0: no se encontró la orden
./crontab: línea 37: 0: no se encontró la orden
./crontab: línea 42: a2billing.conf: no se encontró la orden
./crontab: línea 46: */2: No existe el fichero o el directorio << this file exist in the correct path...!!
./crontab: línea 50: 14: no se encontró la orden
./crontab: línea 51: a2billing.conf: no se encontró la orden
./crontab: línea 52: a2billing.conf: no se encontró la orden
./crontab: línea 53: a2billing.conf: no se encontró la orden
./crontab: línea 55: a2billing.conf: no se encontró la orden
./crontab: línea 56: a2billing.conf: no se encontró la orden
./crontab: línea 57: a2billing.conf: no se encontró la orden
./crontab: línea 58: a2billing.conf: no se encontró la orden
well, CentOS does not have "Run As " in the ROOT's crontab, it's in "/etc/crontab"
take a look here, it will be much clearer what you're doing wrong.
I really still lossed in this, as in ubuntu I never had such as issue with the same cron...
As noboddy I can't run the crons, as this may make me problems into the system... I have deleted the a2billing user, and add the user as: useradd -M -s /sbin/ a2billing, but still getting the same command not found error...
which i can't understand, why the root crons are not working also, as they are the default OS crons, as:
Quote:
root run-parts /etc/cron.hourly
/bin/bash: root: command not found
Which is coming by default into the OS, and I haven't played with...?!
I really don't know what is the cause and I would try to do it from scratch to see if working. BUT FIRST make a backup of your crontabs (root's and /etc)
for example when 'root' you can do:
Code:
# crontab -l >~/crontab-backup-04-2012
Then you can copy /etc/crontab:
Code:
# cp -pv /etc/crontab /etc/crontab-backup-04-2012
now after the backup, you can delete root's crontab (being user root) with
Code:
# crontab -r
then make a new crontab with
Code:
# crontab -e
and put in something to check if it's working, like create a file in some directory
this should create a file every minute, in the path /var/tmp and filename like "testfile-2012-04-13.00", "testfile-2012-04-13.01", "testfile-2012-04-13.02"
Then you can gradually proceed adding tasks to root's crontab.
root’s crontab is not /etc/crontab. Only the latter has a six’th field for the user to be used to run this entry. Obviously it’s specified as “root”, but during execution treated like being the executing command.
I really don't know what is the cause and I would try to do it from scratch to see if working. BUT FIRST make a backup of your crontabs (root's and /etc)
for example when 'root' you can do:
Code:
# crontab -l >~/crontab-backup-04-2012
Then you can copy /etc/crontab:
Code:
# cp -pv /etc/crontab /etc/crontab-backup-04-2012
now after the backup, you can delete root's crontab (being user root) with
Code:
# crontab -r
then make a new crontab with
Code:
# crontab -e
and put in something to check if it's working, like create a file in some directory
# this should test the proper execution
*/1 * * * * touch /var/tmp/testfile-$(date +"%F-%H.%M")
With this I got the mail as:
Quote:
touch /var/tmp/testfile-$(date +"...
/bin/bash: -c: line 0: unexpected EOF while looking for matching `"'
/bin/bash: -c: line 1: syntax error: unexpected end of file
touch /var/tmp/testfile-$(date +"...
/bin/bash: -c: line 0: unexpected EOF while looking for matching `"'
/bin/bash: -c: line 1: syntax error: unexpected end of file
and nothing else (because the format of the command needs proper syntax)
You can read more about Crontab. It will be helpful.
Now onto your second problem with "command not found"
Quote:
Originally Posted by Ubunter
And same for:
Code:
:
0 0 * * * root rm -rf /tmp/*
/bin/bash: root: command not found
It really can not be found because it's not properly set in crontab !
Code:
0 0 * * * root rm -rf /tmp/*
this syntax CAN ONLY be used in "/etc/crontab"
and not in the root's or any other user's crontab (which you edit with "crontab -e")!
The format in user's crontab CANNOT contain the column with the username and command to execute, because it's meant to run as the user who created its own crontab (with "crontab -e").
Now try please not putting the username in crontab just the command (this is the way to do it) otherwise you can use (in your root's crontab) sudo command to become other user and execute commands.
The format in user's crontab CANNOT contain the column with the username and command to execute, because it's meant to run as the user who created its own crontab (with "crontab -e").
Now try please not putting the username in crontab just the command (this is the way to do it) otherwise you can use (in your root's crontab) sudo command to become other user and execute commands.
Thanks again lithos,
I'm doing and testing this since 2 days, the root crontab seem to be working, unless today i got this report by mail:
Quote:
/etc/cron.daily/mlocate.cron:
/usr/bin/updatedb: `/var/lib/mlocate/mlocate.db' is locked (probably by an earlier updatedb)
But as you said, i have re-edit the /etc/crontab, and put my commands without the username, as:
But this last one still not working nothing, the test is not running, and I can't find any report in the log for this crontab...
The unique way, which I got it to work is to run the crons without user, into the root crontab as crontab -e I add the lines, and now, i see there log as running into the root, but not as custom /etc/crontab... I don't know if this is correct, it's working, but it's correct?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.