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.
#!/bin/bash --login
# if [ "`crontab -l | grep -v '#' | grep home.sh | wc -l`" = 0 ]; then `echo "5 * * * * /home/userName/hello.sh" >> $1`; fi
if [ "`incrontab -l | grep -v '#' | grep home.sh | wc -l`" = 0 ]; then `echo "/home/userName/test-dir IN_CREATE /home/userName/hello.sh" >> $1`; fi
As you can see there are two enteries in each file. One for normal crontab and other one for incrontab. When i run "test-incrontab.sh" like following;
Code:
./test-incrontab.sh
crontab works perfectly and i can see cron job set but for incrontab it just does not work. No error either! I am only getting this back "table unchanged"
I have been trying to fix this for last 5,6 hours but no luck at all
Any ideas????
Regards,
A.Malik
Last edited by abubakar-malik; 03-09-2011 at 02:52 AM.
Hi Tom, here is the information you asked for. I hope it will help.
I am writing the commands and their corresponding ouput;
Command: cat /etc/redhat-release
Code:
Red Hat Enterprise Linux Server release 5.4 (Tikanga)
Command: cat /proc/version
Code:
Linux version 2.6.18-164.10.1.el5 (mockbuild@hs20-bc2-5.build.redhat.com) (gcc version 4.1.2 20080704 (Red Hat 4.1.2-46)) #1 SMP Wed Dec 30 18:35:28 EST 2009
Command: uname -r
Code:
2.6.18-164.10.1.el5
Command: uname -a
Code:
Linux nameoftheMachine 2.6.18-164.10.1.el5 #1 SMP Wed Dec 30 18:35:28 EST 2009 x86_64 x86_64 x86_64 GNU/Linux
I know this topic is old, but the question is a good one and deserves a complete answer.
The reason why you get the "table unchanged" error is because incrontab command checks for the mtime of the tmp file before installing it. And since "echo" does not change the file's update time, to get your script to work, you need to add a command to update the mtime, the "addlinetocrontab.sh" script becomes:
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.