1 Reply Latest reply on Sep 14, 2020 2:47 AM by DanJGF

    Simple SH script started with cron job, will not persist and settings/files are deleted after reboot.

    MarcusHO Lurker



      I created a simple little script to do a rescan of the storage adapters on the server, 60 seconds after boot.


      I created a file called hbascan.sh and in that file i have this line "sleep 60s;esxcli storage core adapter rescan --all"

      I placed this script in the /bin folder on the ESXi host


      I edited the "/var/spool/cron/crontabs/root" in here i added "@reboot sh /bin/hbascan.sh" at the end/bottom of the file.

      I then killed the Cron job after finding the correct ID


      I then edited the "/etc/rc.local/" and added at the end of the file 3 rows with text.


      /bin/kill $(cat /var/run/crond.pid)

      /bin/echo '@reboot sh /bin/hbascan.sh' >> /var/spool/cron/crontabs/root

      /bin/busybox crond


      I saved the file and ran the command "sh /sbin/auto-backup.sh"


      Problem is that when i reboot the server everything is gone, the script is gone and the changes to root and rc.local is also gone.

      I did the edit of the files with winscp as i am not really confident in "vi"


      I am not entirely sure what's wrong, it could be syntax or maybe file rights?

      I followed a guide for this online and it's almost identical to the guide, only i did not provide any path to logs.


      Any help would be greatly appreciated.