Is there a way to safely close down Chromium from the command-line?

5,492

Use SIGTERM:

pkill -15 chromium-browser

or:

pkill chromium-browser

the default value is -15 equal to SIGTERM.

From Wikipedia:

The SIGTERM signal is sent to a process to request its termination. Unlike the SIGKILL signal, it can be caught and interpreted or ignored by the process. This allows the process to perform nice termination releasing resources and saving state if appropriate. SIGINT is nearly identical to SIGTERM.

PS: pkill -3 chromium was only an illustration of how may a session lost happen.

Share:
5,492

Related videos on Youtube

Broadsworde
Author by

Broadsworde

Updated on September 18, 2022

Comments

  • Broadsworde
    Broadsworde over 1 year

    Is there a way using command-line/bash to safely close down Chromium (running multiple tabs), that will not cause the application to shutdown incorrectly.

    Using (for example):

    $ pkill -3 chromium
    

    (man signal shows -3 indicates the signal SIGQUIT)

    (which I understand is how the shutdown command would terminate an application)
    Causes Chromium to give the following error message when you next start it:

    enter image description here

  • Broadsworde
    Broadsworde over 5 years
    Thanks again @Ravexina. Would you be able to elaborate on the difference between pkilling chromium vs chromium-browser, and why shutdown, reboot and logout are not using this safe termination method in their processes?
  • Ravexina
    Ravexina over 5 years
    I'm sure the commands you mentioned are sending the correct SIGNAL, they used to send SIGTERM. The Idea with SIGTERM is that the process (chromium in this case) can decide what to do. Because the system is getting shutdown chromium may decides to inform you that your session suddenly has been lost (Not by you) or it does not have enough time to cleanly close itself and system goes down before it get cleanly shutdown (chromium). My example in your previews question was only intended to reproduce the error.
  • Ravexina
    Ravexina over 5 years
    pkill chromium may terminate other process which they name contains chromium while pkill chromium-browser will only terminate the browser (uniqe name) it's even better to use it like pkill -x chromium-browser (x exact name).
  • Jaime Hablutzel
    Jaime Hablutzel almost 5 years
    In Ubuntu 18.04, how could I make this to be executed immediately after triggering a restart or a shutdown?