PDA

Bekijk de volledige versie : Add Crontab jobs to images



DerFuchs
10-05-2005, 15:48
Hi.

Some programs should be executed every five minutes. Its easy to set up a cronjob table by hand after loging on the router, but if I try to make them part of the image they do not work. The crontab file is part of the image since I can see on the router; but calling: crontab -e exits with:
" crontab: unable to create /var/spool/cron/crontab.316 "

my crontabfile:
* * * * * /bin/foo # foo is called each minute

Makefile:
install:
mkdir -p $(INSTALLDIR)/var/spool/cron/crontabs
install -D crontab $(INSTALLDIR)/var/spool/cron/crontabs/admin

Is there an other way to store 'static' crontabs? I think I could set them up via post-boot procedure but I though it would be prettier to do it this way.

kind regards
DerFuchs

barsju
10-05-2005, 16:16
Why not just add /var/spool/cron/crontabs/admin to /usr/local/.files?
Store it in flashfs..

S.

DerFuchs
10-05-2005, 17:35
Why not just add /var/spool/cron/crontabs/admin to /usr/local/.files?
Store it in flashfs..

Does it mean that /var/spool/cron/crontabs/admin would survive a firmware upgrade?

The firmware has to be deployed on nine routers. Thats why I prefer one ready-to-go firmware which can be upload via webinterface. Telnet and friends are also disabled for security reasons.

kind regards
DerFuchs

Oleg
10-05-2005, 17:40
Type flashfs save and you will see a flashfs image. Then read /sbin/flashfs script to understand the things.

tomilius
11-05-2005, 01:24
Is there an other way to store 'static' crontabs? I think I could set them up via post-boot procedure but I though it would be prettier to do it this way.

Do a recursive grep through the source for files containing the term "post-boot." I don't know exactly when it's called, but that'll tell you. You could put your crond command there, after post-boot is called.

barsju
11-05-2005, 07:53
Does it mean that /var/spool/cron/crontabs/admin would survive a firmware upgrade?

Yes it will survive, but not be enabled. For that you need to type "flashfs enable".

So as I see it you can use Tomilius's way and have a one-step installation, but you will need to recompile each new FW.
Or you can use my way, avoiding the recompile but having a two-step installation.

You should be able to use curl to make a script for upgrading all nine at once using the hidden admin page to call flashfs enable.

S.

DerFuchs
11-05-2005, 08:27
Do a recursive grep through the source for files containing the term "post-boot." I don't know exactly when it's called, but that'll tell you. You could put your crond command there, after post-boot is called.

Thank you. I found the post-boot call in rc/rc.c added eval("/bin/cronfoo.sh") which calls the setup cronjob script and rebuild the image. Everything is working now the expected way.