1

In BleachBit, if I go to Edit > Preferences > General, I can check the "Start BleachBit with computer" checkbox, but this will only launch the BleachBit GUI every time I start my computer, without actually cleaning.

BleachBit Preferences

Instead, I would prefer to run the BleachBit CLI silently in the background and do the cleaning automatically using my presets, using the following command:

bleachbit -c --preset

I have tried setting up a cron job with the @reboot option. I also tried adding an entry in /etc/rc.local but neither method worked.

Is there any simple way to do it?

codeaviator
  • 1,757

2 Answers2

1

This answer has been adapted from Takkat's answer answering the question How do I start applications automatically on login?

Option 1: Editing the desktop configuration file manually

When the "Start BleachBit with computer" checkbox is activated, it creates a desktop configuration file called bleachbit in ~/.config/autostart/. This is very well explained in the posts Where are startup commands stored? and where is “startup applications” user config file for disabled and enabled applications?

desktop configuration file in autostart

If you want to access the folder with nautilus make sure to enable View > Show Hidden Files, or use the Ctrl+H shortcut.

Edit the file with your text editor of choice, for example using gedit. Open the terminal and run the command:

gedit ~/.config/autostart/bleachbit

Inside the file, locate the line Exec=bleachbit and replace it with:

Exec=bleachbit -c --preset

Save the changes. We're done.

Notice that after saving, the desktop configuration file is renamed automatically to bleachbit.desktop. This is default behavior.

renamed desktop configuration file in autostart


Option 2: Using the gnome-session-properties interface

If you prefer not to mess around with the desktop configuration file, you can use the gnome-session-properties interface, which will do that for you.

First, open BleachBit and make sure that the "Start BleachBit with computer" checkbox is activated.

Next, open the terminal and run:

gnome-session-properties

The man page reads:

DESCRIPTION

The gnome-session-properties program enables the users to configure what applications should be started on login, in addition to the default startup applications configured on the system.

It also proposes an interface to save a snapshot of the currently running applications so that they can automatically be restored to their current state on your next GNOME session.

It will open the Startup Applications Preferences panel:

Startup Applications Preferences

Select the "BleachBit" entry and click on "Edit".

Locate the "Command" field and replace the string with bleachbit -c --preset

Edit Startup Program

Edit Startup Program

Click on "Save". We're done.

codeaviator
  • 1,757
0

What line did you use to set up the cron job? I have a few set up to run on boot on my server and they work perfectly.

In my own crontab file (in /var/spool/crontabs) this is one of the working entries

@reboot /home/will/scripts/bootup.sh   #notify of boot

I set this up through webmin but I'd guess it's the context that matters and not how it got there.

have you tried the command with the full bleachbit path?

I like to set up a dedicated script to run as a cron job or any other automated startup that isn't set up by the system itself, then I can test the script to make sure my command is correct and works, it makes it easier to troubleshoot issues I think.

Will
  • 655