Cron Problem Yet Again - openSUSE Tumbleweed Linux

Get help for specific problems
Posts: 6
Joined: 17 Feb 2024

richardstevenhack

I know, I've searched the forum and found all sorts of cron job solutions - that aren't working for me.

I'm running KDE on openSUSE Tumbleweed, latest snapshot, in fact a fresh install yesterday. I installed Task Scheduler in KDE.

Here is my original cron job:
rhack@localhost:/Data2/Work> crontab -l
#No comment
DISPLAY=:0

#No comment
0 5 * * *     /usr/bin/flatpak run --branch=stable --arch=x86_64 --command=FreeFileSync --file-forwarding org.freefilesync.FreeFileSync  "/Data2/Documents/Computer/Computer - System Information/System Backups/FreeFileSync Backup Batch File/BatchRun.ffs_batch"  2>>/Data2/Work/backuperror.log

# File generated by KCron the Monday, February 19, 2024 4:07:17 PM PST.
I've done a dozen modifications to this over the last day and nothing works.

Note that when run from the KDE Task Scheduler or from the command line, the above command runs perfectly well. Sync is performed, a summary is displayed and an error log is written.

The error in the log is "Gtk-Message: 16:27:56.032: Failed to load module "canberra-gtk-module" but this has absolutely no effect on whether the job runs or not from the Task Scheduler "Run Now" or from the command line. Apparently this missing module is associated with the sound libraries and openSUSE has it named differently than expected.

When scheduled to run by the Task Scheduler, the task apparently starts - but does absolutely nothing. Examining the journal shows the job starts on schedule, never shows any CPU time consumed.
Feb 19 16:50:11 localhost.localdomain systemd[2461]: Started app-flatpak-org.freefilesync.FreeFileSync-4042.scope.
Feb 19 16:50:42 localhost.localdomain systemd[2461]: app-flatpak-org.freefilesync.FreeFileSync-4042.scope: Consumed 1min 7.012s CPU time.
Feb 19 16:51:00 localhost.localdomain CRON[4317]: (rhack) CMD (/usr/bin/flatpak run --branch=stable --arch=x86_64 --command=FreeFileSync --file-forwarding org.freefilesync.FreeFileSync  "/Data2/Documents/Computer/Computer - System Information/System Backups/FreeFileSync Backup Batch File/BatchRun.ffs_batch"  2>>/Data2/Work/backuperror.log)
As you see above, the first run at 16:50:11 is run from Task Scheduler. It runs and completes. The second run at 16:51:00 runs - but does nothing and never completes. It hangs as shown below:
rhack@localhost:/Data2/Work> ps -ef | grep freefilesync
rhack     6824  6823  0 17:02 ?        00:00:00 /bin/sh -c /usr/bin/flatpak run --branch=stable --arch=x86_64 --command=FreeFileSync --file-forwarding org.freefilesync.FreeFileSync  "/Data2/Documents/Computer/Computer - System Information/System Backups/FreeFileSync Backup Batch File/BatchRun.ffs_batch"  2>>/Data2/Work/backuperror.log
rhack     6825  6824  8 17:02 ?        00:00:00 /usr/bin/flatpak run --branch=stable --arch=x86_64 --command=FreeFileSync --file-forwarding org.freefilesync.FreeFileSync /Data2/Documents/Computer/Computer - System Information/System Backups/FreeFileSync Backup Batch File/BatchRun.ffs_batch
rhack     6854  2876  0 17:03 pts/1    00:00:00 grep --color=auto freefilesync
It apparently hangs until I kill it manually from the terminal using kill -9 <pid>.

The batch file itself looks like this:
<?xml version="1.0" encoding="utf-8"?>
<FreeFileSync XmlType="BATCH" XmlFormat="23">
    <Notes/>
    <Compare>
        <Variant>TimeAndSize</Variant>
        <Symlinks>Exclude</Symlinks>
        <IgnoreTimeShift/>
    </Compare>
    <Synchronize>
        <Differences LeftOnly="right" LeftNewer="right" RightNewer="right" RightOnly="right"/>
        <DeletionPolicy>RecycleBin</DeletionPolicy>
        <VersioningFolder Style="Replace"/>
    </Synchronize>
    <Filter>
        <Include>
            <Item>*</Item>
        </Include>
        <Exclude>
            <Item>*/.Trash-*/</Item>
            <Item>*/.recycle/</Item>
            <Item>*lost+found</Item>
        </Exclude>
        <SizeMin Unit="None">0</SizeMin>
        <SizeMax Unit="None">0</SizeMax>
        <TimeSpan Type="None">0</TimeSpan>
    </Filter>
    <FolderPairs>
        <Pair>
            <Left>/Data15</Left>
            <Right>/run/media/rhack/Backup15/Data15</Right>
        </Pair>
        <Pair>
            <Left>/Data7</Left>
            <Right>/run/media/rhack/Backup7/Data7</Right>
        </Pair>
        <Pair>
            <Left>/Data4</Left>
            <Right>/run/media/rhack/Backup4/Data4</Right>
        </Pair>
        <Pair>
            <Left>/Data3</Left>
            <Right>/run/media/rhack/Backup3/Data3</Right>
        </Pair>
        <Pair>
            <Left>/Data2</Left>
            <Right>/run/media/rhack/Backup2/Data2</Right>
        </Pair>
    </FolderPairs>
    <Errors Ignore="false" Retry="0" Delay="5"/>
    <PostSyncCommand Condition="Completion"/>
    <LogFolder>/Data2/Work/</LogFolder>
    <EmailNotification Condition="Always"/>
    <GridViewType>Action</GridViewType>
    <Batch>
        <ProgressDialog Minimized="true" AutoClose="false"/>
        <ErrorDialog>Show</ErrorDialog>
        <PostSyncAction>None</PostSyncAction>
    </Batch>
</FreeFileSync>
I am completely at my wit's end. If necessary, I'll just run the batch job manually before I go to bed at night, but it irritates me that this scheduled cron job runs perfectly fine from Task Scheduler and the terminal, but not from cron itself.
Posts: 309
Joined: 7 Jan 2018

bgstack15

Is it possible that flatpak needs more environment variables to correctly connect to the desktop or otherwise run? Have you tried with some other flatpak program in cron, to see if it operates?

Can you try inserting the DISPLAY=:0 on the same line with the command, in front of the command flatpak?

Are you expecting this to run when you are not logged in on the default graphical console (tty1 or tty7 usually), and therefore user rhack does not own DISPLAY :0?
Posts: 6
Joined: 17 Feb 2024

richardstevenhack

/quote]

"Is it possible that flatpak needs more environment variables to correctly connect to the desktop or otherwise run?"

That's a good question. I'm not sure. This is the KDE desktop and in my experience it has all sorts of things that might need to be done. When I was running fwbackups it used to put a command about the dbus on the line. Researching that led into the weeds about KDE and I gave up. I tried the command that fwbackups used and it didn't work. I'll have to revisit that and try another test.

"Can you try inserting the DISPLAY=:0 on the same line with the command, in front of the command flatpak?
"
At one point I did have the DISPLAY command on the same line. Didn't change anything. This is how KDE Task Scheduler works: you put all the variables you want cron to use in the Variable section of Scheduler and they're inserted as shown. So it should work as shown and FreeFileSync shouldn't care if cron doesn't.

"Are you expecting this to run when you are not logged in on the default graphical console (tty1 or tty7 usually)"

No, I'm logged in 24x7. It's a single user desktop.

"Have you tried with some other flatpak program in cron, to see if it operates?"

That's a good idea. I'm going to try running fwbackups again in a test and copy the exact command it used replacing the fwbackups specific command with the FreeFileSync command. I suspect that the problem either involves the KDE dbus or alternatively some issue between FreeFileSync and openSUSE Tumbleweed specifically.bgstack15, 22 Feb 2024, 12:54
Posts: 6
Joined: 17 Feb 2024

richardstevenhack

Well, nothing worked.

I tried the same command as Fwbackups was using but pointing it at FFS - didn't work,

I removed the flatpak version of FFS and installed the run file version.

Nothing worked.

This is the last crontab I tried:
rhack@localhost:/Data2/Work> crontab -l

#No comment
33 0 * * *      DISPLAY=:0 /usr/local/bin/FreeFileSync "/Data2/Documents/Computer/Computer - System Information/System Backups/FreeFileSync Backup Batch File/BatchRun.ffs_batch" 1>>/Data2/Work/backup.log 2>>/Data2/Work/backuperror.log


# File generated by KCron the Friday, February 23, 2024 12:06:57 AM PST
That crontab did manage to run FFS, but all I get from the error log is a constant:
"Authorization required, but no authorization protocol specified" repeated over and over very quickly.

Researching that led me into a rabbit hole of something called Xauthority which apparently is used to grant scripts access to the X11 server. I tried setting the Xauthority to the one in my home directory as some Web posts suggested, but there is no Xauthority file in my home directory. Apparently all that has changed - again - making ninety percent of Web documentation absolutely useless - which is a constant in OSS operating systems.

I give up. I'm just going to run FFS manually every night before I go to bed. It's just pathetic that existing operating systems make this sort of thing stupidly impossible. I can't wait for AI to take over this crap and put programmers on the unemployment line.
Posts: 309
Joined: 7 Jan 2018

bgstack15

Does SUSE Tumblewood/your setup use Wayland?

Does KDE still use SDDM for the display manager (login screen)? Maybe you can do this, from https://wiki.archlinux.org/title/SDDM#X_authority_(aka_MIT-MAGIC-COOKIE)_file:
33 0 * * *    DISPLAY=:0 XAUTHORITY="$( find /var/run/sddm/ -type f )" /usr/local/bin/FreeFileSync
Posts: 6
Joined: 17 Feb 2024

richardstevenhack

Tumbleweed still uses x11 by default and that's what I'm running.

KDE on Tumbleweed uses SDDM.

I looked at the article you provided. However, yesterday I did a reassignment of Xauthority to my home directory - and was unable to login. Fortunately I have another machine so I did some research and determined that removing Xauthority and rebooting would allow login.

In short, this stuff requires too much research to avoid bonking the system entirely. I can't trust any advice in this area because it's either 1) wrong; 2) out-of-date, i.e., wrong, and 3) dangerous to mess with without detailed knowledge of how KDE, cron and a myriad other things work.

I've been using Linux for years but there are limits to my detailed knowledge of how things work at this point.

So I think I'll pass on another experiment and just run FFS manually. It takes 15 minutes to run the job manually - and that's scanning over 10 million files - and I can do something else while it runs. So automating it probably isn't worth the effort or the risk of damaging the system by playing with system files I don't understand and can't understand without days of research.

I wish there was an actual book on KDE which explains how it all works. I have the official documentation Web pages, but unless I want to spend a week or more going through them - and it's hard to do that effectively with Web pages (every such site should have a PDF version, but they don't) it's just not worth the effort. I just downloaded 3 books "on KDE" and they all deal with the end user available facilities and absolutely nothing on the internals.

OSS documentation is frankly pathetic.

And even if there was a book - it would be out of date with the next release of either KDE or the OS using it. Just trying to find where the Xauthority was on openSUSE led me to two difference places: $XAUTHORITY environment variable points to a different place than /var/run/sddm.

So I give up and will run things manually until FFS implements cron jobs itself like Fwbackups does.

Thanks for your help.
Posts: 44
Joined: 14 Aug 2022

daviank

I don't know for SuSE, but in Debian, there is a field to set the username under which the command should be run. Is "username" field of your cron file correctly set?
# Example of job definition:
# .---------------- minute (0 - 59)
# |  .------------- hour (0 - 23)
# |  |  .---------- day of month (1 - 31)
# |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...
# |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# |  |  |  |  |
# *  *  *  *  * user-name command to be executed

17 *    * * *   root    cd / && run-parts --report /etc/cron.hourly
Posts: 44
Joined: 14 Aug 2022

daviank

According to your logs, command is run with the correct user.
Posts: 44
Joined: 14 Aug 2022

daviank

Could this be related to SELinux?
Posts: 6
Joined: 17 Feb 2024

richardstevenhack

Tumbleweed doesn't run SELinux by default; it runs AppArmor which is similar. Your question motivated me to check by reviewing the AppArmor documentation. According to that, running the command "aa-unconfined" as root shows programs which are "confined" or "unconfined." According to that, cronie is "unconfined" meaning there is no security profile assigned to it.

As for the user, I tried explicitly setting the user and that had no effect.
Posts: 6
Joined: 17 Feb 2024

richardstevenhack

Poking around, I determined how to list both cron and FFS log entries in the system journal (openSUSE does not use /var/log/syslog). The logs showed cron executing FFS and FFS executing. However, I also saw a lot of these messages:
Feb 22 03:31:41.985883 FreeFileSync[17269]: Failed to load module "canberra-gtk-module"
Feb 22 03:54:39.174199 FreeFileSync[17269]: GFileInfo created without standard::is-hidden
Feb 22 03:54:39.174209 FreeFileSync[17269]: file ../gio/gfileinfo.c: line 1633 (g_file_info_get_is_hidden): should not be reached
Feb 22 03:54:39.174214 FreeFileSync[17269]: GFileInfo created without standard::is-backup
Feb 22 03:54:39.174219 FreeFileSync[17269]: file ../gio/gfileinfo.c: line 1655 (g_file_info_get_is_backup): should not be reached
Feb 22 03:54:43.512919 FreeFileSync[17269]: GFileInfo created without standard::is-hidden
Feb 22 03:54:43.512935 FreeFileSync[17269]: file ../gio/gfileinfo.c: line 1633 (g_file_info_get_is_hidden): should not be reached
Feb 22 03:54:43.512943 FreeFileSync[17269]: GFileInfo created without standard::is-backup
Feb 22 03:54:43.512951 FreeFileSync[17269]: file ../gio/gfileinfo.c: line 1655 (g_file_info_get_is_backup): should not be reached
These appear to be coming from the GTK system (which I know nothing about.) I don't how this could be related to the "authorization required" message that was continuously repeated when FFS ran. The "GFileino" function appears to be used to retrieve file information as indicated here:
https://gtk-rs.org/gtk-rs-core/stable/0.19/docs/gio/struct.FileInfo.html

Beyond that, there is nothing in the logs that indicates what is the cause of the "Authorization" message.

I've really spent WAY too much time on this, so I think it's best if we just stop discussing it. I'm curious as to why it's not working but I just don't have the time to find out.
Posts: 309
Joined: 7 Jan 2018

bgstack15

@daviank, what you missed is that the user ran crontab -l as a regular user, so it was just going to use his user, with no field for setting it because he cannot change it. Otherwise, in a root-controlled /etc/crontab or /etc/cron.d/ file, you can set the username.