Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
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.
Here is the steps I've done. Please correct me if I made anything wrong. My cron job is not working
Code:
user@localhost:~> ls -lh test.dat
/bin/ls: test.dat: No such file or directory
user@localhost:~> date
Sat Nov 28 19:18:33 GMT+4 2009
user@localhost:~> crontab -e
crontab: no changes made to crontab
user@localhost:~> crontab -e
crontab: installing new crontab
user@localhost:~> crontab -l
# DO NOT EDIT THIS FILE - edit the master and reinstall.
# (/tmp/crontab.XXXXkkSAid installed on Sat Nov 28 19:18:52 2009)
# (Cron version V5.0 -- $Id: crontab.c,v 1.12 2004/01/23 18:56:42 vixie Exp $)
19 19 * * * /bin/echo "test" >> /opt/user/test.dat
user@localhost:~> date
Sat Nov 28 19:18:56 GMT+4 2009
user@localhost:~> date
Sat Nov 28 19:19:02 GMT+4 2009
user@localhost:~> ls -lh test.dat
/bin/ls: test.dat: No such file or directory
user@localhost:~>
Yes, I 've permission on that folder as I can create a file there
Quote:
user@localhost:~> touch tet
user@localhost:~> ls tet
tet
user@localhost:~>
I opened /var/log/messages file and see the following lines:
Nov 28 19:18:52 localhost crontab[4279]: (user) END EDIT (user)
Nov 28 19:18:54 localhost crontab[4283]: (user) LIST (user)
Nov 28 19:19:01 localhost /usr/sbin/cron[4405]: (user) RELOAD (tabs/user)
Could you explain why the following cron is not working?
Quote:
user@localhost:~> date
Mon Nov 30 13:17:43 GMT+4 2009
user@localhost:~> crontab -l
# DO NOT EDIT THIS FILE - edit the master and reinstall.
# (/tmp/crontab.XXXXvnPD7i installed on Mon Nov 30 13:17:37 2009)
# (Cron version V5.0 -- $Id: crontab.c,v 1.12 2004/01/23 18:56:42 vixie Exp $)
18 13 * * * /bin/echo "test" >> /opt/user/test.dat
user@localhost:~> date
Mon Nov 30 13:18:02 GMT+4 2009
user@localhost:~> ls -lh test.dat
/bin/ls: test.dat: No such file or directory
user@localhost:~> ls -lh /opt/user/test.dat
/bin/ls: /opt/user/test.dat: No such file or directory
user@localhost:~>
crontab -e edits a file in cron's spool folder, where all users' cron jobs are stored.
Each minute, cron will check the spool folder for updates and ingest them if found.
So, if you schedule a job to run on minute 18, while you are on minute 17, it is possible that
cron will miss your update.
Try leaving 2-3 minutes between the time when you change the crontab and the job execution time,
allowing cron to detect and incorporate the update.
Note: this is also why you can't schedule cron jobs to the second (or millisecond) levels: cron only
checks for updates once per minute. Have a look at the cron jobs scheduled in /etc/cron*, like /etc/crontab.
Good advice. Also, if cron has an issue, it'll usually email the cron job owner or root with a summary.
Try mail or mailx at the cli as you and root to see if it said anything.
Thank you guys. I've solved it using and investigating the cron log. There I saw that it doesn't run for the first time, it just RELOAD, but runs for the next time
I have another question, how can I get the current date and time when my cron will run? I configured it, and now want to know the current dates when it will run "without running it"
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.