New on LowEndTalk? Please Register and read our Community Rules.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
Running cronjob on CentOS
german_psycho
Member
in Help
I have a problem running a cronjob on CentOS 6.
I'd like to run a shell-script that gets my home IP and updates the iptables on my VPS.
The script works without problems when started manually.
Now, I want to do the job with cron every 20 or so minutes. I started "crontab -e" and added the following line:
*/20 * * * * /bin/bash /etc/get_ip.sh
The get_ip.sh is exectuable, changed the ownerhip via "chmod +x get_ip.sh", owner is now root (same user the cron is created for).
The problem is: the script isn't executed by cron and I dunno why. There are no errorlogs in /var/log or something, seems it just doesn't work.
Any ideas what the problem may be?
Comments
How if just like this:
Also no luck
This was the first I tried. Even if BASH is defined in the script, to be sure it's executed I added it to the cronlist. Both ways don't work. Crond is running, so I am running out of ideas what causes this problem.
The cron log is in /var/log/cron, you should find your scripts there.
No logfile, either
Would cron create a log, even if it exited without errors? Haven't ever checked this..
Maybe I should just add a job where it creates a file or similiar, just to check if cron executes at all.
Type "env" in ssh and look for a line like this:
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
Then add the entire line to the top of crontab -e after the hashed out sections and before your scripts line.
Yeah, it finally works.
Thanks alot, guys!