© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
AdmincraftA
Admincraft•2y ago•
8 replies
xtalvrge

Server failing to restart (session.lock)

Greetings, I've managed to get the server set up and working except for the one small thing, when server tries to restart - it generates a session.lock files in all worlds and it fails to restart. I'm thinking the issue could be due to my launch scripts. This is what I'm currently running:

start.sh //

#!/bin/sh

# Define the screen session name
SESSION_NAME="mc_spigot_server"

# Check if a screen session with the specified name already exists
if screen -list | grep -q "$SESSION_NAME"; then
    echo "Killing existing screen session: $SESSION_NAME"
    screen -S "$SESSION_NAME" -X quit
fi

# Start a new screen session with the specified name
echo "Starting new screen session: $SESSION_NAME"
screen -d -m -S "$SESSION_NAME" ./startserver.sh
#!/bin/sh

# Define the screen session name
SESSION_NAME="mc_spigot_server"

# Check if a screen session with the specified name already exists
if screen -list | grep -q "$SESSION_NAME"; then
    echo "Killing existing screen session: $SESSION_NAME"
    screen -S "$SESSION_NAME" -X quit
fi

# Start a new screen session with the specified name
echo "Starting new screen session: $SESSION_NAME"
screen -d -m -S "$SESSION_NAME" ./startserver.sh


startserver.sh //

#!/bin/bash

JAR=server.jar
MAXRAM=12884M
MINRAM=8192M
TIME=10


while [ true ]; do
    java -Xmx$MAXRAM -Xms$MINRAM -jar $JAR nogui
    if [[ ! -d "exit_codes" ]]; then
        mkdir "exit_codes";
    fi
    if [[ ! -f "exit_codes/server_exit_codes.log" ]]; then
        touch "exit_codes/server_exit_codes.log";
    fi
    echo "[$(date +"%d.%m.%Y %T")] ExitCode: $?" >> exit_codes/server_exit_codes.log
    echo "----- Press enter to prevent the server from restarting in $TIME seconds -----";
    read -t $TIME input;
    if [ $? == 0 ]; then
        break;
    else
        echo "------------------- SERVER RESTARTS -------------------";
    fi
done
#!/bin/bash

JAR=server.jar
MAXRAM=12884M
MINRAM=8192M
TIME=10


while [ true ]; do
    java -Xmx$MAXRAM -Xms$MINRAM -jar $JAR nogui
    if [[ ! -d "exit_codes" ]]; then
        mkdir "exit_codes";
    fi
    if [[ ! -f "exit_codes/server_exit_codes.log" ]]; then
        touch "exit_codes/server_exit_codes.log";
    fi
    echo "[$(date +"%d.%m.%Y %T")] ExitCode: $?" >> exit_codes/server_exit_codes.log
    echo "----- Press enter to prevent the server from restarting in $TIME seconds -----";
    read -t $TIME input;
    if [ $? == 0 ]; then
        break;
    else
        echo "------------------- SERVER RESTARTS -------------------";
    fi
done


Has anybody encountered a similar issue, and if so - would you please help me out?

Big thanks! 😄
AdmincraftJoin
10,704Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Server restart script
AdmincraftAAdmincraft / questions
3y ago
session locked?
AdmincraftAAdmincraft / questions
3y ago
forge server failing to start
AdmincraftAAdmincraft / questions
2y ago
batch file to automatically restart server?
AdmincraftAAdmincraft / questions
3y ago