Ok i am checking, but why did you use \ between green and :lan or :wan. Using \ and not using it, gives different results, at one time 1 other time 0 . Like here:
_______ ________ __
| |.-----.-----.-----.| | | |.----.| |_
| - || _ | -__| || | | || _|| _|
|_______|| __|_____|__|__||________||__| |____|
|__| W I R E L E S S F R E E D O M
-----------------------------------------------------
OpenWrt 23.05.2, r23630-842932a63d
-----------------------------------------------------
root@openwrt:~# cd /sys/class/leds/
root@openwrt:/sys/class/leds# ls
amber:wan green:lan green:power green:wan green:wlan-2 green:wlan-5 mt76-phy0 mt76-phy1
root@openwrt:/sys/class/leds# cd green:lan
root@openwrt:/sys/class/leds/green:lan# ls
brightness device_name link rx trigger uevent
device interval max_brightness subsystem tx
root@openwrt:/sys/class/leds/green:lan# cd bin
-ash: cd: can't cd to bin: No such file or directory
root@openwrt:/sys/class/leds/green:lan# cd
root@openwrt:~# cd bin
-ash: cd: can't cd to bin: No such file or directory
root@openwrt:~# ls
leds_off leds_on trigger?
root@openwrt:~# cd /
root@openwrt:/# ls
bin etc mnt proc root sys usr www
dev lib overlay rom sbin tmp var
root@openwrt:/# cd bin
root@openwrt:/bin# ls
ash date grep mkdir passwd sh uclient-fetch
board_detect dd gunzip mknod pidof sleep umount
busybox df gzip mktemp ping sync uname
cat dmesg ipcalc.sh mount ping6 tar vi
chgrp echo kill mv ps touch zcat
chmod egrep ln netmsg pwd traceroute
chown false lock netstat rm traceroute6
config_generate fgrep login nice rmdir true
cp fsync ls opkg sed ubus
root@openwrt:/bin# cd echo
-ash: cd: can't cd to echo: Not a directory
root@openwrt:/bin# cd
root@openwrt:~# cd
root@openwrt:~# cat /sys/class/leds/green\:lan/brightness
1
root@openwrt:~# cat /sys/class/leds/green:lan/brightness
0
root@openwrt:~# cat /sys/class/leds/green\:lan/brightness
1
root@openwrt:~#
Yes it worked each time I executed the 4 variations of your command as below :
_______ ________ __
| |.-----.-----.-----.| | | |.----.| |_
| - || _ | -__| || | | || _|| _|
|_______|| __|_____|__|__||________||__| |____|
|__| W I R E L E S S F R E E D O M
-----------------------------------------------------
OpenWrt 23.05.2, r23630-842932a63d
-----------------------------------------------------
root@openwrt:~# /bin/echo "0" > /sys/class/leds/green\:lan/brightness
root@openwrt:~# /bin/echo "1" > /sys/class/leds/green\:lan/brightness
root@openwrt:~# /bin/echo "0" > /sys/class/leds/green:lan/brightness
root@openwrt:~# /bin/echo "1" > /sys/class/leds/green:lan/brightness
root@openwrt:~#
Verify that the scripts do what you want by directly invoking them in SSH.
In the LuCI interface, go to System → Scheduled Tasks and enter your desired crontab entries. Look up "cron syntax" with your favorite search engine to learn more. For example, to turn on LEDs at 6:00 AM and turn off LEDs at 9:00 PM:
0 6 * * * /root/leds_on
0 21 * * * /root/leds_off
as for \ is escaping special characters like : being interpreted as commands instead of file/folder names as we want it - google it up
Now again an issue as below of permission denied :
_______ ________ __
| |.-----.-----.-----.| | | |.----.| |_
| - || _ | -__| || | | || _|| _|
|_______|| __|_____|__|__||________||__| |____|
|__| W I R E L E S S F R E E D O M
-----------------------------------------------------
OpenWrt 23.05.2, r23630-842932a63d
-----------------------------------------------------
root@openwrt:~# ls
leds_off leds_on trigger?
root@openwrt:~# rm trigger?
root@openwrt:~# ls
leds_off leds_on
root@openwrt:~# ls
leds_off leds_on ledsoff2.sh ledson2.sh
root@openwrt:~# ls
leds_off leds_on ledsoff2.sh ledson2.sh
root@openwrt:~# cat /sys/class/leds/green:lan/brightness
1
root@openwrt:~# cat /sys/class/leds/green:wan/brightness
1
root@openwrt:~# ./ledsoff2.sh
-ash: ./ledsoff2.sh: not found
root@openwrt:~# sh ledsoff2.sh
: Permission denied: can't create /sys/class/leds/green:lan/brightness
root@openwrt:~# chmod +x ledsoff2.sh
root@openwrt:~# chmod +x ledson2.sh
root@openwrt:~# sh ledsoff2.sh
: Permission denied: can't create /sys/class/leds/green:lan/brightness
root@openwrt:~# cd /
root@openwrt:/# sh ledsoff2.sh
sh: can't open 'ledsoff2.sh': No such file or directory
root@openwrt:/# cd
root@openwrt:~# sh ledsoff2.sh
: Permission denied: can't create /sys/class/leds/green:lan/brightness
root@openwrt:~# sh ledson2.sh
: Permission denied can't create /sys/class/leds/green:lan/brightness
root@openwrt:~#
I inferred that I can execute all commands individually from shell also echo none > trigger which turn off leds too as before as seen in below 2nd output but not from script file which again brings us back to initial issue of script file not executing commands :
I did some variation of my own in crontab as already told by @maurer and its working, still last 2 problems left to solve after careful observation :
# Reboot at 12:00am every day
# Note: To avoid infinite reboot loop, wait 70 seconds
# and touch a file in /etc so clock will be set
# properly to 12:01am on reboot before cron starts.
0 0 * * * sleep 70 && touch /etc/banner && reboot
#
# enable all LEDs at 4am
0 4 * * * /bin/echo "1" > /sys/class/leds/green:lan/brightness ; /bin/echo "1" > /sys/class/leds/green:wan/brightness ; /bin/echo "1" > /sys/class/leds/green:power/brightness ; /bin/echo "1" > /sys/class/leds/green:wlan-2/brightness ; /bin/echo "1" > /sys/class/leds/green:wlan-5/brightness
# disable all LEDs at 9pm
0 21 * * * /bin/echo "0" > /sys/class/leds/green:lan/brightness ; /bin/echo "0" > /sys/class/leds/green:wan/brightness ; /bin/echo "0" > /sys/class/leds/green:power/brightness ; /bin/echo "0" > /sys/class/leds/green:wlan-2/brightness ; /bin/echo "0" > /sys/class/leds/green:wlan-5/brightness
A) A/c to my settings in crontab all 5 leds turn off at 9 pm, system reboot occurs at 12 am, and finally leds turn on at 3 am (but at this step, after turning on, all 5 leds' state are continuous on instead of the setting done for them which is blinking state according to link, tx and rx activity. Note that this is my 1st problem)
B) Secondly, I have a logical query as my 2nd problem. If all 5 leds are turned off at 9 pm, then will they still be kept off after system reboot completes at 12 am ?
For point 1 you need the script in post 3
For point 2 - no the leds will be on (defaults) so you need to issue another off command let's say 5minutes after the router rebooted
Thanks, this is better than having nothing but its a little less absolute trick than my original tp link stock firmware where leds turned off immediately after reboot completed without any confusion of how to implement led turn off with absolute timing without defining any timings.
It works as intended but not exactly. But better than having nothing. Trying if the commands can be polished more to be absolute and as I exactly intend.
Sorry, I didn't mean that in a negative sense. I've had people "helpfully" withhold important information when asking for help (which of course is frustrating). But I realize that it sounds accusatory after a second read, so I removed that bit in my reply since that isn't my intention.
I still don't know why cd doesn't work here, but it appears just using the absolute path works.
When you turn off the LEDs, the kernel erases the trigger state. If you want to restore the blinkenlights you also need to also write the tx, rx, link, and device_name files in addition to writing netdev to trigger.
Thank you for taking time to explain to a noob like me. And don't be sorry because I didn't take it negatively. You mentioned you doubt and I clarified it. Its just that. And also I understand you position where someone is trying to help someone who is knowingly or unknowingly withholding info which makes matter frustrating to help further so don't feel that I am taking it negatively. I understand that and thanks for helping me
Well we can implement this in openwrt as well.
I suggest to open a new thread and I'm sure someone with more time currently (kids vacation time) can help you
Finally I found reason for this error of " can't find cd to directory..." coming when executing script over ssh and now I can execute scripts over ssh to continue forward to solve LED timing feature.
Look here in these 2 photos :
Script created in Windows Notepad & viewed in Windows Notepad :
Script created in Windows Notepad & viewed in Linux Vim :