Difference between revisions of "Adding crond"

From ElphelWiki
Jump to: navigation, search
(Created page with "=Adding Cron Daemon= Installation of Cron Daemon into the Elphel353 Philip Carinhas<br> Fortuitous Technologies Inc<br> http://fortuitous.com<br> I. Introduction Crond and cro...")
 
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
=Adding Cron Daemon=
+
=Adding the Cron Scheduler Daemon into 8.X=
Installation of Cron Daemon into the Elphel353
+
By: Philip Carinhas http://fortuitous.com
  
Philip Carinhas<br>
+
== Synopsis: This covers the Installation of Cron Daemon into the Elphel353 using the 8.X firmware ==
Fortuitous Technologies Inc<br>
 
http://fortuitous.com<br>
 
  
 
I. Introduction
 
I. Introduction

Latest revision as of 10:55, 30 November 2010

Adding the Cron Scheduler Daemon into 8.X

By: Philip Carinhas http://fortuitous.com

Synopsis: This covers the Installation of Cron Daemon into the Elphel353 using the 8.X firmware

I. Introduction

Crond and crontab are part of busybox in the Axis embedded distro.
Activating these is easy, but you need to add a few extra ingredients
to complete the process.

II. Installation:

0. Set some environment vars:

  <root@cam>: AXIS_TOP_DIR=/path/to/your/elphel-dev-kit-base
  <root@cam>:  cd $AXIS_TOP_DIR

1. Go into the busybox area (which is where crond is integrated)

  <root@cam>:  cd packages/apps/busybox

2. configure crond and crontab in busybox:

  <root@cam>:  make menuconfig
   ==> Miscellaneous Utilities
    --> Select Crond
    --> Select Crontab
    --> exit, exit, save when asked

3. This config isn't the real one, you must copy it into busyboxconfig to make it stick:

  <root@cam>:  diff .config busyboxconfig
  <root@cam>:  cp .config busyboxconfig

4a. Now add the init script in the SDK to create the right directory inside the FOX fimage end the script to start and stop the crond daemon.
Go in the packages/initscripts folder and create a folder named crond:

  <root@cam>:  cd $AXIS_TOP_DIR/packages/initscripts
  <root@cam>:  mkdir crond
  <root@cam>:  cd crond


4b. Now copy inside it these files: rc, conf, Makefile as follows:


First we'll make these files with cat:

<root@cam>: cat << ENDOFIT > rc
#! /bin/sh

. /etc/init.d/functions.sh
. /etc/conf.d/crond

case "$1" in
        start)
                begin "Starting crond"
                crond $CROND_OPTIONS
                end $?
                ;;
        stop)
                begin "Stopping crond"
                killall crond
                end $?
                ;;
        *)      
        error "Usage: $0 start|stop"
        ;;
esac
ENDOFI
<root@cam>:  cat << ENDOFIT > conf
CROND_OPTIONS="" 
ENDOFIT
  • Note: On this next one: Make sure that the following has TABS in the indented lines or "make" will fail!
    I've tried to cut-and-paste these linesto check for consistency, but its not 100% accurate. Depends on your editor.
<root@cam>:  cat << ENDOFIT > Makefile
include \$(AXIS_TOP_DIR)/tools/build/Rules.axis

OWN = -o root -g root


install:
	\$(INSTALL) \$(OWN) -m 0755 rc "\$(prefix)"/etc/init.d/crond
	\$(INSTALL) \$(OWN) -m 0644 conf "\$(prefix)"/etc/conf.d/crond
	\$(LN) -sf ../init.d/crond "\$(prefix)"/etc/rc0.d/K90crond
	\$(LN) -sf ../init.d/crond "\$(prefix)"/etc/rc1.d/K90crond
	\$(LN) -sf ../init.d/crond "\$(prefix)"/etc/rc2.d/K90crond
	\$(LN) -sf ../init.d/crond "\$(prefix)"/etc/rc3.d/S90crond
	\$(LN) -sf ../init.d/crond "\$(prefix)"/etc/rc4.d/S90crond
	\$(LN) -sf ../init.d/crond "\$(prefix)"/etc/rc5.d/K15crond
	\$(LN) -sf ../init.d/crond "\$(prefix)"/etc/rc6.d/K15crond
        
	mkdir "\$(prefix)"/var/spool
	mkdir "\$(prefix)"/var/spool/cron
	mkdir "\$(prefix)"/mnt/flash/crontabs
	touch "\$(prefix)"/mnt/flash/crontabs/root
        
	\$(LN) -sf /mnt/flash/crontabs "\$(prefix)"/var/spool/cron/crontabs
ENDOFIT

5. Go back to the SDK root folder and edit the main Makefile.

 <root@cam>:  cd $AXIS_TOP_DIR
 <root@cam>:  vi Makefile
   -> Search for SUBDIRS list:
   -> Add "packages/initscripts/crond" to end of list
   -> You will have to add a continuation backslash to the prior line

6. Make the image as usual:

  <root@cam>:  make (or use Kdevelop)

7. FBI WARNING: since there is no Mail services on elphel, all stderr and stdout must be handled in your crontab.
Otherwise crond can fail, certainly your scripts will fail.

<root@cam>: cat << ENDOFIT > ~/root.cron
# Sample crontab file
*/2 * * * * /bin/echo "cron is good" >> /mnt/flash/root/cron_check.out 2>&1
ENDOFIT

8. Now test:

<root@cam>: crontab root.cron
<root@cam>: crontab -l