Score:0

Unable to access jarfile in a tmux session from startup

bb flag

I have a script which starts a new tmux session and runs the Minecraft launch command like so:

#!/bin/bash

# Create a new session and run a command inside the session
tmux new-session -d -s mc
tmux set-option -t mc set-remain-on-exit on
tmux send-keys -t mc "java -Xmx6G -jar fabric-server-mc.1.19.4-loader.0.14.19-launcher.0.11.2.jar nogui" Enter

I'm able to run a similar script manually and it launches just fine, I'm able to see the Minecraft server run and access it's CLI from there. I say "similar script" but it just lacks the set-remain-on-exit on (needed to run tmux from crontab) and attaches the session, it has nothing to do with the issue.

While I've used crontab to launch this script at startup and tmux does work, all that shows up after attaching the session is:

Error: Unable to access jarfile fabric-server-mc.1.19.4-loader.0.14.19-launcher.0.11.2.jar

I've tried chmod +x, chmod 755, and chmod 777 for the script, but no such luck. I'm not sure why the jarfile cannot be accessed when launched from crontab, would anyone know why?

Edit: Attempting to specify the entire java path (/usr/bin/java) also doesn't help.

I've found that when loading it from anywhere outside the directory it's in, the jarfile will be inaccessible, naturally this also affects cron, so how would I fix this, at least for cron?

Score:0
bb flag

To fix it, I needed to add the directory in the launch script to specify the where the jarfile is, despite the launch script being in the same place.

#!/bin/bash

#set the working directory
cd /home/minecraft/fabric-1.19.4

# Create a new session and run a command inside the session
tmux new-session -d -s mc
tmux set-option -t mc set-remain-on-exit on
tmux send-keys -t mc "java -Xmx6G -jar fabric-server-mc.1.19.4-loader.0.14.19-launcher.0.11.2.jar nogui" Enter
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.