I have installed fcrontab for the user user1. I have a .net web application through which users can schedule the jobs. For this I’m editing the the file “/var/spool/fcron/user1.orig” through c# file operation methods. I’m able to edit the file and I can see the changes by “fcrontab -l” terminal command. But unfortunately the scheduled jobs are not running as they are scheduled in fcrontab.
If I edit the fcrontab through “fcrontab -e” terminal command, the jobs are running as they are scheduled in fcrontab!
I have given read and write permission for the folder “/var/spool/fcron” to the users user1 and www-data and I have no issues editing the file “/var/spool/fcron/user1.orig”. Do I need to run anything else so that fcron will notice the changes in fcrontab and so it will rebuild itself?
It looks like once you edit fcrontab file, you have to update fcron. There is an option to send the signal by “fcronsighup” which instructs fcron to reread the fcron tables. I tried it but it doesn’t works.
Then I came up with idea of having temp file, and edit the temp file rather than fcrontab file and then replace the fcrontab with tempfile through script. Replacing the file through script ensures that fcron will reread modified fcron tables.
Instructions on how to replace fcrontab file can be found here:
http://fcron.free.fr/doc/en/faq.html
(look for How can I use fcrontab in scripts?)
And it works!