4

I shut down Firefox at night by running killall -s SIGTERM firefox via cron, in order to apply the package manager and browser addon updates. Unfortunately each time when the browser is (manually) restarted, a 'restore session' tab about:sessionrestore is opened, obviously indicating that Firefox doesn't consider this as a clean exit. I'm relying on the 'delete cookies and site data when Firefox is closed' feature (with some domain exceptions) which supposedly has the potential to misbehave when the Firefox processes are killed.

The session data in the profile folders in ~/.mozilla/firefox/ does contain some private data and bloats my backups (not necessarily easy to filter out). rsync has to some degree reported that specific files in the directory have been changed during the transfer. I rotate between several Firefox profiles on two or more workspaces and closing each manually borders on nonfeasible.

The Mozilla documentation doesn't mention any such feature. A related question about Google Chrome (/ Chromium).


Any Wayland-friendly solutions (including, potentially, Selenium and some sensible macros) are also accepted.

user598527
  • 437
  • 2
  • 17
  • 1
    According to https://bugzilla.mozilla.org/show_bug.cgi?id=336193#c73 there used to be a way years ago, but not any more. – muru Jul 12 '22 at 07:01
  • 1
    You could use the window manager (e.g. `wmctrl`) to close it as you would manually... – pLumo Jul 12 '22 at 07:28
  • @pLumo about `wmctrl` — I'm Wayland-only, sorry for forgetting to add the tag. – user598527 Jul 12 '22 at 07:57
  • 1
    Have a look at [`ydotool`](https://github.com/ReimuNotMoe/ydotool) then. It simulates input rather than interacting with the Xserver. Should be available in most standard repos. – FelixJN Jul 12 '22 at 08:11

1 Answers1

0

Please try something like this (is you have a single firefox profile - this might not work if you have two instances of Firefox running with two different profiles):

kill `ps -ej | grep -v grep | grep firefox | head -1 | awk '{print $1}'`

This works here just fine and I don't see any messages in regard to "Your session has been restored".

The command "kills" (sends the TERM signal which is a normal way of terminating applications in Linux) only the parent Firefox process which is how it's meant to be closed.

Artem S. Tashkinov
  • 26,392
  • 4
  • 33
  • 64