0

I am trying to run a java program inside a screen session at boot, I am using the following cron, but after reboot screen -ls shows no active screen sessions.

@reboot /usr/bin/screen -dmS myservice "java -jar /home/david/myservice/MyService-0.0.1-SNAPSHOT.jar"

Any idea what I am doing wrong?

EDIT:

I did change it to the following and the screen does start at boot now.

@reboot /usr/bin/screen -dmS myservice && "java -jar /home/david/myservice/MyService-0.0.1-SNAPSHOT.jar"

I added && before starting the java command and not the screen does start at boot. But the program is still not running.

but the program is not running when I attach to the screen. after attaching to the screen all I see is a dollar sign.

Arya
  • 131

1 Answers1

0

It's possible your distro, or your implementation of cron, doesn't support @reboot at all, or fully, or for all users. It's a tricky one.

screen might not be a good way to launch a service either, but either way, I'd recommend an alternative to cron for this. This tutorial covers initialising services at boot across a few different system configurations, and might be what you need.

Johnny
  • 180