IMO something is wrong with permissions. I guess your script is executed with not-root privileges, right? And it fails. And when you run it from console, you run it as a root. Maybe spoiled filesystem, or it is really mounted as not Linux partition or whatever else. I would suggest to delete partition, create it again as a Linux (fdisk) and then format it by mkfs.ext4.
the purpose of the script is to be usable as cron job. i used to have 5 cron scripts that worked perfect for 6 months and after moving entware to another USB stick they stop working anymore.
By trial and error tests I determined that they don't work because CD command don't work anymore in script. But it seems CD command works perfectly from the shell. So I had to replace the relative links with absolute links to make all my old scripts work again with cron.
1) I have executed the script from shell using:
cd "/opt/somedir"
./test.sh"
logged as root
2) I have also executed "test.sh" using cron, and I have checked (with htop) cron service is launched by root user.
my entware/dropbear user config uses symlinks to router users (the files in opt/etc/ are symlinks to /etc/) . so my root user is the root of the router NOT the root of entware (alternative installation).
Both metods are not working!
So until today I have tested this:
- tried with old entware (december 2016)
- tried new entware version (june 2017)
- tried with USB stick, tried with esata SSD
- tried format EXT2 and EXT3 (to both usb stick and esata ssd)
- tried old firmare 1.0.2.15SF
- tried new firmware 1.0.2.33SF
- reseted router settings from software and manually reconfigured them (like 3-4 times before and after upgraded the firmware), visually checked nvram ("nvram show") from the shell to see I found something strange.
IT'S NOT WORKING and now the entware drive is Linux type for sure:
"fdisk -l"
Code:
Disk /dev/sda: 55.9 GiB, 60022480896 bytes, 117231408 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xe3897863
Device Boot Start End Sectors Size Id Type
/dev/sda1 2048 117231407 117229360 55.9G 83 Linux
as you can see partition type is Linux now. this is my esata drive.
What i did not tried is to do yet is:
- check if the problem with CD in the scripts is the same if I use router flash memory (no usb/esata connected). so script to be in router flash and also cd command (working directory) to be on router flash.
- remake the partitions of external drives (usb, esata)
- format partions as EXT4
P.S. is there an utility/command to check if router flash disk have errors?