Reboot my Linode?

Linode Staff

What is the correct/quickest way to reboot my Linode?

7 Replies

You can reboot your Linode via the Cloud Manager by navigating to your Linode's Dashboard, clicking "Running" near the upper-right corner of the page, and then clicking "Reboot".

If you have the Linode CLI installed, you can also do this using commands like the following (or even copy them exactly into a script):

# Specify which Linode to reboot
Label="$1"

# This will show your Linode's ID number.
LinodeID=$(linode-cli linodes list --text | grep "$Label" | awk '{print $1}')

# Perform a proper, host level reboot, equivalent to pressing
# the button in the Manager.
linode-cli linodes reboot $LinodeID 

After giving it execute permissions with a command like chmod +x script.sh, you can invoke the reboot script as script.sh label, where label is the name of the Linode you wish to reboot. The script will then parse out the Linode's ID, and pass it to the linode-cli linodes reboot command. These commands (or script) would have to be run from a machine which has the CLI installed on it in order to work. To run these commands outside of a script, just replace $1 in the first line with the label for the Linode that you wish to reboot.

@tommydavidson: When using this method, will systemd services be stopped cleanly, e.g. allow ExecStop to run? If not, what is the recommended method of performing a clean shutdown or reboot?

I think I've been able to answer my own question by enabling a systemd service file that creates a file as its ExecStop= script, then rebooting using the CLI. After the reboot, the file existed, which means that as far as I can tell, all systemd services are stopped cleanly.

If you do not have the Linode CLI installed, or do not wish to install/use it for any reason, you can also reboot using a direct call to our API:

curl -H "Content-Type: application/json" \
    -H "Authorization: Bearer $TOKEN" \
    -X POST \
    https://api.linode.com/v4/linode/instances/$LINODEID/reboot

You'll just need to replace $TOKEN with your API token, and $LINODEID with your Linode's ID. You can obtain a list of your Linode IDs with the following API call:

curl -H "Authorization: Bearer $TOKEN" \
    https://api.linode.com/v4/linode/instances

If you haven't already, you can find instructions for creating an API token here. I recommend parsing that output with a tool like jq to make it more readable:

curl -H "Authorization: Bearer $TOKEN" \
    https://api.linode.com/v4/linode/instances | jq

The following commands will check for a jq installation, and install it for you if one is not present:

# Check if jq is installed, and install it if it's not 
if [ ! -x /usr/bin/jq ]; then
    wget https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64
    mv jq-linux64 jq
    chmod +x jq
    mv jq /usr/bin/
fi

Is there a proper way to reboot the linode from the instance itself? If I issue a soft reboot command on console, i.e. # reboot - the instance just shuts itself off.

@relet

That is the behaviour of Linodes - a reboot effectively stops the instance at the “power off” stage so all services are shut down cleanly.

The “Lassie” watchdog will then pick up that it’s stopped, check if this was due to an explicit shut down request via Manager or the API and, if not, will power it back on again.

In my time with Linode, Lassie hasn’t failed me yet. Check your Linode’s Settings page and make sure the “shutdown watchdog” is enabled.

Previous posts on this thread show you how to trigger a reboot from the command-line, which can be run from your Linode itself, using cURL, the API or the linode-cli application.

Lassie will only reboot the Linode automatically IF the “Shutdown Watchdog” (under “Settings” in the Cloud Manager) is enabled (it's enabled by default on new Linodes).

If this setting is enabled then [sudo] reboot [now] or [sudo] shutdown -P from any logged-in terminal will (safely) reboot the Linode.

— sw

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct