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.
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.
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
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.