Error When Running Under Cron

Asked by Varnus Zell

Hello,
I always get the message below when running bleachbit as a cronjob:

"
Unable to init server: Could not connect: Connection refused
Unable to init server: Could not connect: Connection refused

(bleachbit:xxxxx): Gdk-CRITICAL **: xx:xx:xx.xxx: gdk_screen_get_root_window: assertion 'GDK_IS_SCREEN (screen)' failed
"

I don't get this error when running from a terminal prompt

It doesn't seem to cause any real problems and bleachbit works well, but I find the message really annoying and wonder if anyone has an idea why it happens and how to fix it.

Thanks!

Question information

Language:
English Edit question
Status:
Answered
For:
BleachBit Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Andrew Ziem (ahziem1) said :
#1

@Varnus

Which version of BleachBit? You can check by adding the --sysinfo to the command line.

Revision history for this message
Varnus Zell (varnus) said :
#2

user@machine:~$ bleachbit --sysinfo
BleachBit version 4.1.1
Git revision 940c1c39
GTK version 3.24.20
GTK theme = Theme
GTK icon theme = IconTheme
GTK prefer dark theme = False
SQLite version 3.31.1
local_cleaners_dir = None
locale_dir = /usr/share/locale/
options_dir = /home/user/.config/bleachbit
personal_cleaners_dir = /home/user/.config/bleachbit/cleaners
system_cleaners_dir = /usr/share/bleachbit/cleaners
locale.getdefaultlocale = ('en_US', 'UTF-8')
os.getenv('DESKTOP_SESSION') = cinnamon
os.getenv('LOGNAME') = user
os.getenv('USER') = user
os.getenv('SUDO_UID') = None
os.path.expanduser('~') = /home/user
platform.linux_distribution() = ('LinuxMint', '20', 'ulyana')
platform.platform = Linux-5.4.0-58-generic-x86_64-with-glibc2.29
platform.version = #64-Ubuntu SMP Wed Dec 9 08:16:25 UTC 2020
sys.argv = ['/usr/bin/bleachbit', '--sysinfo']
sys.executable = /usr/bin/python3
sys.version = 3.8.5 (default, Jul 28 2020, 12:59:40)
[GCC 9.3.0]
__file__ = /usr/share/bleachbit/Diagnostic.py
user@machine:~$

Revision history for this message
Andrew Ziem (ahziem1) said :
#3

From cron, do you you try to clean system.clipboard or anything that might include it such as system.* or --preset ?

Revision history for this message
Varnus Zell (varnus) said :
#4

Yes, I do use --preset in the crontab once every 24 hours, but running a crontab as root or non-root without --preset gives the same error. For example, the text posted above was the output from this cronjob:
bleachbit --overwrite --clean firefox.backup firefox.cache firefox.cookies firefox.crash_reports firefox.dom firefox.forms firefox.session_restore firefox.site_preferences > /home/user/Desktop/bleachlog 2>&1 ;
If I run the above from a terminal rather than from cron, I do not get that error.

Revision history for this message
Andrew Ziem (ahziem1) said :
#5

OK, I am seeing that in the latest revision (git e5076cf63ef0535fa4d629565580d6a08710c15f). For reference, the problem seems to be in Cleaner.py where it imports Gtk, which it needs to clean the clipboard (even if clipboard is not requested). It also uses it to determine whether to offer the clipboard as an option. There is code to ignore a warning here, but apparently it does not work.

In more plain terms, the reason for the error is the application is trying to start a GUI, which is not available under cron. It does this even when using the command line interface, like you are using in cron.

Would you file a bug report here?
https://github.com/bleachbit/bleachbit/issues/new/choose

Can you help with this problem?

Provide an answer of your own, or ask Varnus Zell for more information if necessary.

To post a message you must log in.