Run elasticsearch on startup

Hi there,

I installed Nextcloud on Windows with WSL 2 and ElasticSearch. All is working great but I’m unable to run ElasticSearch on Windows Startup.

I managed to have MYSQL, APACHE2 and CRON running on startup with this solution:

  • adding %sudo ALL=NOPASSWD: /etc/init.d/mysql start with sudo visudo

  • adding %sudo ALL=NOPASSWD: /etc/init.d/apache2 start with sudo visudo

  • adding %sudo ALL=NOPASSWD: /etc/init.d/cron start with sudo visudo

  • Create a shortcut in shell:startup with arguments: “C:\Program Files\WindowsApps\CanonicalGroupLimited.Ubuntu20.04LTS_2004.4.5.0_x64__79rhkp1fndgsc\ubuntu2004.exe” run sudo /etc/init.d/mysql start

  • Create a shortcut in shell:startup with arguments: “C:\Program Files\WindowsApps\CanonicalGroupLimited.Ubuntu20.04LTS_2004.4.5.0_x64__79rhkp1fndgsc\ubuntu2004.exe” run sudo /etc/init.d/apache2 start

  • Create a shortcut in shell:startup with arguments: “C:\Program Files\WindowsApps\CanonicalGroupLimited.Ubuntu20.04LTS_2004.4.5.0_x64__79rhkp1fndgsc\ubuntu2004.exe” run sudo /etc/init.d/cron start

So, logically I tried to do the same for ElasticSearch but the service doesn’t start.

That’s strange because I can start the service when I launch the WSL 2 CLI and type: “sudo service elasticsearch start”

Any idea?

Thanks in advance.
Franck