How to configure cron on WP76?

Hello All,

I am trying to include the cron to my yocto (release Morty) image. In the image recipe I have added IMAGE_INSTALL_append = " cronie". This created the crontab and cron.d directory in /etc/. Also other directories like /etc/cron.daily/, /etc/cron.hourly/, are created. But when I flash the image to the board and try to add the cron job using crontab -e I get below error:

/var/spool/cron: No such file or directory
/var/spool/cron: mkdir: No such file or directory

Also when I try to start crond daemon with /etc/init.d/crond start I get below error

Starting crond: /var/spool/cron: No such file or directory
/var/spool/cron: mkdir: No such file or directory
FAIL

I noticed that these directories doesn’t exist. The filesystem is read-only.
Is there anything I am missing in the image during build? How can I add cron jobs using crontab -e in this case? My cron jobs should run every 20mins.

I am working with WP76.

you can do this:


root@swi-mdm9x28-wp:~# mkdir /tmp/tmp_var;mkdir /tmp/tmp_var_wr;

root@swi-mdm9x28-wp:~# mount -t overlay overlay /var -o lowerdir=/var,upperdir=/tmp/tmp_var,workdir=/tmp/tmp_var_wr;

root@swi-mdm9x28-wp:~# mkdir /var/spool
root@swi-mdm9x28-wp:~# mkdir /var/spool/cron
root@swi-mdm9x28-wp:~# echo 123 > /var/spool/cron/123.txt
root@swi-mdm9x28-wp:~# cat /var/spool/cron/123.txt
123

Hello @jyijyi thanks for quick update.
Can I add this mount overlayfs entry to /etc/fstab? Becasue I would like to do this automatically and also mkdir /tmp/tmp_var;mkdir /tmp/tmp_var_wr should be done during image build.

No, you cannot, /etc/fstab is not a directory

BTW, you can run an unsandboxed legato app to run a script to do the overlay in each boot up:

Hi @jyijyi , sorry maybe I was not clear earlier. I want to add mount -t overlay overlay /var -o lowerdir=/var,upperdir=/tmp/tmp_var,workdir=/tmp/tmp_var_wr; to /etc/fstab. Because after reboot, the overlayfs entry doesnot exist. So, I need to make this permanent

you can make a script like this:


root@swi-mdm9x28-wp:~# cat /home/root/overlay_test.sh
sleep 30
mkdir /tmp/tmp_var;mkdir /tmp/tmp_var_wr;
mount -t overlay overlay /var -o lowerdir=/var,upperdir=/tmp/tmp_var,workdir=/tmp/tmp_var_wr;

root@swi-mdm9x28-wp:~# chmod 777 /home/root/overlay_test.sh

And then in /etc/init.d/startlegato.sh , add the following line to call the script during power on:



case "$1" in
    start)
        echo "Legato start sequence"

        umount /legato 2>/dev/null
        mount -o bind $LEGATO_MNT /legato

        test -x $LEGATO_START && $LEGATO_START

#jyi
sh /home/root/overlay_test.sh &

Thank you @jyijyi , after adding mkdir -p /var/spool/cron and /etc/init.d/crond start to overlay_test.sh, it works. Otherwise cron service will not start after boot.