LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   crontab not working (https://www.linuxquestions.org/questions/linux-newbie-8/crontab-not-working-877102/)

etika 04-26-2011 02:29 AM

crontab not working
 
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

# m h dom mon dow user command
*/5 * * * * root echo "****************"|mail -s "eeeee" [emailabc@gmail.com[/email]
55 * * * * root cd / && run-parts --report /etc/cron.hourly


what could be the possible reasons of /etc/crontab(systemwide cron) not working
Please help

repo 04-26-2011 02:36 AM

What doesn't work?
Any pointers in the logfiles, mail from cron to root?
Cron uses a limited path, so try to give the whole path to the commands and files.

Kind regards

16pide 04-26-2011 03:34 AM

what is this / for in:
*/5
and why do you mention "root" in those lines?

Have a look in http://adminschoice.com/crontab-quick-reference for syntax and examples

Also, how did you get crontab list? did you launch:
crontab -l

brownie_cookie 04-26-2011 03:45 AM

Quote:

Originally Posted by etika (Post 4336468)
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

# m h dom mon dow user command
*/5 * * * * root echo "****************"|mail -s "eeeee" abc@gmail.com
55 * * * * root cd / && run-parts --report /etc/cron.hourly


what could be the possible reasons of /etc/crontab(systemwide cron) not working
Please help

OFFTOPIC
I would strongly suggest that you hide your e-mailaddress

repo 04-26-2011 04:24 AM

Quote:

Originally Posted by 16pide (Post 4336514)
what is this / for in:
*/5

Code:

*/5 * * * *
will execute the cron every 5 minutes


Kind regards

16pide 04-27-2011 02:03 AM

I did not know the */5 syntax, but tried it, and it works.
There is still the issue with "root" mentioned on every line, and I'm sure this won't work.

Also, why do you mention the SHELL and PATH variables???
Please remove this from the crontab entries

Here is what I suggest you put in your cron (using crontab -e)

<quote>
5 * * * * echo "****************"|mail -s "eeeee" abc@gmail.com
55 * * * * cd / && run-parts --report /etc/cron.hourly
*/1 * * * * echo cron-works>/tmp/cron-works.txt
</quote>

you should see a file created in /tmp every minute (check with ls -l)

16pide 04-27-2011 02:08 AM

using crontab -e, enter this AND ONLY THIS in your crontab:
Code:

*/5 * * * * echo "****************"|mail -s "eeeee" abc@gmail.com
55 * * * * cd / && run-parts --report /etc/cron.hourly
*/1 * * * * echo cron-works>/tmp/cron-works.txt

After a minute you should see the file /tmp/cron-works.txt be created
And maybe your other cron lines now work because I removed "root" from them
And also, I removed the variables definition you had put at the beginning (I don't think this is crontab syntax.

Anyway, start with exactly this, and if my */1 line works, then you have a model

repo 04-27-2011 04:38 AM

Quote:

There is still the issue with "root" mentioned on every line, and I'm sure this won't work.
You are correct, linux cron doesn't have a user field.
Gives an error message, but the cron is executed.

Kind regards


All times are GMT -5. The time now is 06:06 AM.