ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
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.
the /etc/crontab you use is a system wide crontab file and has a special syntax, which differs from "ordinary" user crontab files:
Code:
# /etc/crontab
Min Hour MDay Month WDay User Command
# user crontab (usually in /var/spool/cron/tabs)
Min Hour MDay Month WDay Command
When you edit a crontab file using "crontab -e" (which I would prefer, it's not sure that a manual editing of a crontab file is noticed by the cron daemon), then you edit the user's crontab, not the system's file.
Besides that: You should keep in mind, that the cron daemon doesn't know the environment, which is defined when you log in. You should use absolute path names every time and define all environment variables you use in your script.
This should make it so that mrtg runs every 5 minutes, however the cron job doesn't even run at all. When I look at the cron logfile, there are no errors or signs that it even tried to execute that line. It's like if it didn't exist.
I've tried scheduling a simple shell script that just creates a folder to see if the issue was mrtg related, but I nothing I add to crontab executes.
I tried editing the /etc/crontab manually and via "crontab -e". I get the same results. Am I missing anything?
As a general point, if cron has a problem running a job, it usually sends a mail to the crontab's owner and/or root. Just use the cli mailx program to check.
Yes, Cron is running (I'm logged in as root whenever I set up a cron job anyway). My scripts have 0775 permissions.
Quote:
As a general point, if cron has a problem running a job, it usually sends a mail to the crontab's owner and/or root. Just use the cli mailx program to check.
This is true, but Cron has to attempt to run the job first. If it doesn't even know it needs to run it, then no emails will be sent out.
When I look at the var/logs/cron all I see is the stuff that runs hourly and daily being executed, nothing about what I set up.
hm, then you should check:
1. Are there entries from cron in the system's messages or warn files?
2. Is cron running as root? Has cron the permissions to read the crontab files?
3. Like I already said: Are there restrictions defined in the cron/allow or cron/deny files?
4. Is cron running in a chroot environment - does he read his configuration from another directory?
5. Does a crontab job (a simple shell script like "/bin/ls /etc") run if you create a cron job for another user (use "crontab -e")?
6. Is a security extension like SELinux active on your system?
The questions may be silly, but somewhere you have to start looking for an answer
Whenever I would do crontab -e, crontab would not save any of the commands I was typing, but I found an article where they suggested making the editor = vi. Once I did that I was able to save my contents and crontab is now working as expected.
I'm running into a similar problem as well and have tried several ways to fix it but just can't seem to get this working right.
My crontab seems to be working as I can enter in a line to append to a file, create a file, etc. However, my line for MRTG doesn't seem to work. I can copy and paste that exact command into my prompt and it runs but I just can't get it to run every 5 minutes.
I have tried editing via 'vi /etc/crontab', crontab -e (on root account and nagios account). I have tried putting a user in the crontab entry. I have tried adding '.' and 'sh' into the entry. I have also verified that the permissions to the needed files are all as they should be. By everything I am seeing this should be working without a problem.
I have also tried to specify the exact time it should run and it still doesn't. Is there something else I am missing??
is there a mail message from the cron daemon for the user, for which you installed the cron job? Normally the cron writes a mail containing errors and stdout from your jobs.
A possible reason: crontab jobs do not get the same environment as logged in users. Probably an environment variable is missing.
Unfortunately I never to work using the /etc/crontab file. I had to use crontab -e. For some reason editing the user's crontab file manually would not work for me either.
When you use crontab -e to add that entry, have to checked in /var/spool/cron to see if that user's crontab has been created? If so, have you check to make sure that whatever you entered in the vi editor actually got saved.
If you've modified the user's crontab manually for whatever reason, use crontab -e to remove whatever entry you made to the file manually, save and quit. Then try to add your entry again using crontab -e.
This is what worked for me a few days ago when an entry would not work for me.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.