What's new
  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

Entware Cron on asus stock firmware

swie99

Occasional Visitor
Hello, I need to run cron task to run my shell script file daily at 03:00 am time/after reboot.
I have successfully installed cron from entware but still no luck with scheduling my script file .
For first test I have added line to start my script every 5 min...
/opt/etc/crontab:
SHELL=/bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/opt/bin:/opt/sbin
MAILTO=""
HOME=/
# ---------- ---------- Default is Empty ---------- ---------- #
*/1 * * * * admin /opt/bin/run-parts /opt/etc/cron.1min
*/5 * * * * admin /opt/bin/run-parts /opt/etc/cron.5mins
01 * * * * admin /opt/bin/run-parts /opt/etc/cron.hourly
02 4 * * * admin /opt/bin/run-parts /opt/etc/cron.daily
22 4 * * 0 admin /opt/bin/run-parts /opt/etc/cron.weekly
42 4 1 * * admin /opt/bin/run-parts /opt/etc/cron.monthly
*/5 * * * * admin /opt/etc/cron.d/S99skrypt2.sh
Else I have problem with privileges as I think:
admin@RT-AC55U:/tmp/home/root# crontab -e
You (admin) are not allowed to use this program (crontab)
See crontab(1) for more information
admin@RT-AC55U:/tmp/home/root#
Normally script works correctly of course.
S99skrypt2.sh:
#!/bin/sh

while ping -q -c 1 -w 1 10.200.1.99 >/dev/null ;
do echo "$(date '+%Y-%m-%d %H:%M:%S') Server responding" 2>&1 >> /opt/log.txt && sleep 10 ;
done ;
echo "$(date '+%Y-%m-%d %H:%M:%S') Server stopped responding" 2>&1 >> /opt/log.txt
 
To solve the privileges problem create /opt/var/spool/cron/cron.allow file with "admin" inside it.
/opt/etc/crontab must be 600 and owned by root user (admin), otherwise it won't be executed.
 

Similar threads

Latest threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Back
Top