Home  >  Support  >  Support Forum  >  Is it possible to run a script via crontab with embedded linux
Welcome to Digi Forum, where you can ask questions and receive answers from other members of the community.

Is it possible to run a script via crontab with embedded linux

0 votes
I have a shell script that I would like to run every 15 minutes. When I try to add an entry to the crontab I get this message:

/ # crontab -e
crontab: chdir(/var/spool/cron/crontabs): No such file or directory

This leads me to believe that crontab is not installed. Is there a way install crontab through DEL (version I am running is 5.9 and the current target is a ConnectCard for i.MX28)? If crontab cannot be installed, what is the best way to run a shell script on startup and every X minutes?
asked Jun 12 in Linux by one1six New to the Community (3 points)

Please log in or register to answer this question.

2 Answers

0 votes
 
Best answer
I just did a test here and it’s working

# mkdir -p /var/spool/cron/crontabs
# crontab –e (add the following line)

*/1 * * * * date >> /crontab-date.log

# crond

Then verify a line with the date gets added each minute:

# tail -f /crontab-date.log

Of course you need to have the system time correctly set (from the network with NTP or manually set)

crond doesn't start automaticaly and you need to address for example the problem of the non-existing /var/spool/cron/crontabs directory. A very good example would be the *S60vsftpd.sh* bootscript. That script also creates needed directories if missing. Adapting it to launch crond should be easy.
answered Jun 13 by LeonidM Veteran of the Digi Community (561 points)
selected Jun 23 by one1six
0 votes
create /var/spool/cron/crontabs folder or use
crontab -c /yourownfolder -e ......
answered Jun 12 by LeonidM Veteran of the Digi Community (561 points)
When I add the folder /var/spool/cron/crontabs folder, I can then do a crontab -e and it allows me to edit the cron tasks.  For example:
@reboot /scripts/check_log.sh
Which moves a log file on boot or restart. However, when I restart, the folder /var/spool/cron/crontabs does not exist.  I tried creating a folder of my own and placing the crontab there, but it looks as it never gets executed.  Is there something else that I'm missing?
Contact a Digi expert and get started today! CONTACT US
...