Install python-crontab:

opkg update
opkg install python-openssl 
opkg install distribute 
easy_install python-crontab
nano /mnt/sda1/setcron.py
#!/usr/bin/python
from crontab import CronTab
tab = CronTab(user='root')
cmd = '/mnt/sda1/on.sh'
# You can even set a comment for this command
cron_job = tab.new(cmd, comment='LED')
cron_job.setall('5 5 * * *')
#writes content to crontab
tab.write()
print tab.render()
chmod 755 /mnt/sda1/setcron.py
/mnt/sda1/setcron.py

The code remove all the Cron  with comment='LED':

nano /mnt/sda1/removecron.py
#!/usr/bin/python
from crontab import CronTab
tab = CronTab(user='root')
tab.remove_all(comment='LED')
tab.write()
print tab.render()
chmod 755 /mnt/sda1/removecron.py
/mnt/sda1/removecron.py

 

Comments powered by CComment