You are not logged in.

#1 2013-06-17 12:57:07

Carl Karl
Member
Registered: 2013-06-12
Posts: 231

Editing systemd scripts with gedit can cause trouble...

I'm sure most of you know, but maybe this is useful for the ones who don't know yet:
Editing systemd scripts with gedit can cause trouble!

I spent quite some time to find out why my network connection gets up so slowly after a resume from suspend. (It took about a minute)
Finally, I found out it's caused by the backup files created by gedit!: I have some scripts in /usr/lib/systemd/system-sleep (for hdparm settings and changing mousebuttons) and I sometimes repolished them. Gedit creates automatically a backup file in this case ending with ~.
The problem is now caused by the following: systemd runs each script file in /usr/lib/systemd/system-sleep, no matter if it ends with ~ or not.

As soon as I deleted all the ~ backup files, my network resume after suspend returned to work fast again. :-)

PS:
To put my observation in numbers:
before deleting the back up ~files in /usr/lib/systemd/system-sleep:

$ systemd-analyze blame
    1min 20.245s systemd-suspend.service
          6.664s NetworkManager-wait-online.service
          1.492s NetworkManager.service

after deleting the ~backup files:

$ systemd-analyze blame
         10.738s systemd-suspend.service
          6.702s NetworkManager-wait-online.service
          1.416s NetworkManager.service

quite a difference...

Offline

#2 2013-06-17 13:16:32

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: Editing systemd scripts with gedit can cause trouble...

It''s a similar case to vim backup files in cron folders.
I once edited my /etc/cron.daily/backup.daily and my vim settings caused the creation of /etc/cron.daily/backup.daily~ , so every day two backups were created ...
I have no idea about gedit, but you can tell vim not to create backup files or create them in e.g. ~/.vimbackups instead of the same directory as the edited file.

Offline

#3 2013-06-17 13:37:45

Psykorgasm
Member
Registered: 2011-11-24
Posts: 178

Re: Editing systemd scripts with gedit can cause trouble...

karol wrote:

I have no idea about gedit, but you can tell vim not to create backup files or create them in e.g. ~/.vimbackups instead of the same directory as the edited file.

I wonder if there is a setting in gedit that keeps the backups by default, or if it has changed to do it by default.
The last time I used gedit (and kate/kwite for that matter) the temporary 'backup' file was always cleaned away after closing the editor.

@Carl Do you have a setting set for this behaviour? Are you not cleanly exiting the editor? Just throwing some ideas out there.

Offline

#4 2013-06-17 14:32:13

Unia
Member
From: Stockholm, Sweden
Registered: 2010-03-30
Posts: 2,486
Website

Re: Editing systemd scripts with gedit can cause trouble...

Gedit does not automatically remove those backup files, it never has. You can disable the creation though, which is what I prefer anyway.


If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres

Offline

#5 2013-06-17 15:11:39

fsckd
Forum Fellow
Registered: 2009-06-15
Posts: 4,173

Re: Editing systemd scripts with gedit can cause trouble...

Not an Arch Discussion. Moving to Applications & Desktop Environments.


aur S & M :: forum rules :: Community Ethos
Resources for Women, POC, LGBT*, and allies

Offline

#6 2013-06-17 17:19:07

Carl Karl
Member
Registered: 2013-06-12
Posts: 231

Re: Editing systemd scripts with gedit can cause trouble...

Psykorgasm wrote:

@Carl Do you have a setting set for this behaviour? Are you not cleanly exiting the editor? Just throwing some ideas out there.

Yes, I found a setting and yes, I exit it cleanly.

The setting is in dconf under org.gnome.gedit.preferences.editor.create-backup-copy
Anyway, I don't know which setting is better as it is sometimes useful to have that backup. But sometimes, as in systemd folders, it can really mess u things as we have seen... ;-)


PS:
I posted it in "arch discussions" because of the relation to systemd which is not arch exclusive but typical for arch.

Offline

#7 2013-06-17 17:27:58

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: Editing systemd scripts with gedit can cause trouble...

You can remove the backups manually or edit a copy of the file (e.g. copy /usr/lib/systemd/system-sleep to ~/.settings) and copy the edited file back to /usr/lib/systemd/system-sleep. Backups in ~/.settings won't hurt you.

Offline

#8 2013-06-17 17:30:21

Carl Karl
Member
Registered: 2013-06-12
Posts: 231

Re: Editing systemd scripts with gedit can cause trouble...

karol wrote:

You can remove the backups manually or edit a copy of the file (e.g. copy /usr/lib/systemd/system-sleep to ~/.settings) and copy the edited file back to /usr/lib/systemd/system-sleep. Backups in ~/.settings won't hurt you.

Yes, that's what I'm going to do from now on.

Offline

Board footer

Powered by FluxBB