LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian
User Name
Password
Debian This forum is for the discussion of Debian Linux.

Notices


Reply
  Search this Thread
Old 09-14-2022, 12:36 PM   #1
tmick
Member
 
Registered: Jun 2005
Location: North Dakota
Distribution: Debian Testing
Posts: 247

Rep: Reputation: 20
Question How to fix a Cron error


Hi all,
I'm getting this error daily:
Code:
Failed to start [Cron] "59 23 * * * /usr/bin/clamscan --exclude-dir=/home/tmick/.clamtk/viruses --exclude-dir=smb4k --exclude-dir=/run/user/tmick/gvfs --exclude-dir=/home/tmick/.gvfs --exclude-dir=.thunderbird --exclude-dir=.mozilla-thunderbird --exclude-dir=.evolution --exclude-dir=Mail --exclude-dir=kmail -i --detect-pua -r /home/tmick --log="$HOME/.clamtk/history/$(date +\%b-\%d-\%Y).log" 2>/dev/null # clamtk-scan".
Loaded: loaded (/var/spool/cron/crontabs/tmick; generated)
     Active: failed (Result: exit-code) since Wed 2022-09-14 04:58:40 CDT; 1s ago
TriggeredBy: ● cron-tmick-tmick-0.timer
       Docs: man:systemd-crontab-generator(8)
    Process: 3067932 ExecStart=/bin/sh /run/systemd/generator/cron-tmick-tmick-0.sh (code=exited, status=1/FAILURE)
   Main PID: 3067932 (code=exited, status=1/FAILURE)
        CPU: 4h 8min 37.583s
But then it seems to succeed(?)
Code:
 
Sep 14 04:58:40 DebianTim sh[3067935]: Data scanned: 55974.41 MB
How do I get it to go away??

Thanks in advance!
 
Old 09-14-2022, 01:19 PM   #2
uteck
Senior Member
 
Registered: Oct 2003
Location: Elgin,IL,USA
Distribution: Ubuntu based stuff for the most part
Posts: 1,173

Rep: Reputation: 501Reputation: 501Reputation: 501Reputation: 501Reputation: 501Reputation: 501
What is this file?
Quote:
/run/systemd/generator/cron-tmick-tmick-0.sh (code=exited, status=1/FAILURE)
Looks like systemd-cron is getting in the way.
 
Old 11-07-2022, 06:52 PM   #3
tmick
Member
 
Registered: Jun 2005
Location: North Dakota
Distribution: Debian Testing
Posts: 247

Original Poster
Rep: Reputation: 20
Sorry, I didn't get the email you replied.
The line your asking about leads nowhere actually. Here's the file it's talking about:
Code:
[Unit]
Description=[Cron] "59 23 * * * /usr/bin/clamscan --exclude-dir=/home/tmick/.clamtk/viruses --exclude-dir=smb4k --exclude-dir=/run/user/tmick/gvfs --exclude-dir=/home/tmick/.gvfs --exclude-dir=.thunderbird --exclude-dir=.mozilla-thunderbird --exclude-dir=.evolution --exclude-dir=Mail --exclude-dir=kmail -i --detect-pua -r /home/tmick --log="$HOME/.clamtk/history/$(date +\%%b-\%%d-\%%Y).log" 2>/dev/null # clamtk-scan"
Documentation=man:systemd-crontab-generator(8)
SourcePath=/var/spool/cron/crontabs/tmick
OnFailure=cron-failure@%i.service
Requires=systemd-user-sessions.service
RequiresMountsFor=/home/tmick

[Service]
Type=oneshot
IgnoreSIGPIPE=false
KillMode=process
ExecStart=/bin/sh /run/systemd/generator/cron-tmick-tmick-0.sh
User=tmick
 
Old 11-07-2022, 08:18 PM   #4
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,702

Rep: Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895
Does running the same command from a terminal window work or show any errors (don't redirect errors and remove the %)?

Quote:
--exclude-dir=/run/user/tmick/gvfs
I am not sure if clamscan checks to verify if an excluded directory is a subdirectory of /home/tmick but since /run isn't this can be removed.

I have not played with systemd-cron so don't know how it interprets the %, if there are any caveats or what it uses for an environment.
 
1 members found this post helpful.
Old 11-08-2022, 12:21 AM   #5
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,843

Rep: Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309
That clamscan line is just the Description, not relevant, not executed. Actually would be nice to have a correct description instead of that.
From the other hand you need to check what's wrong with that /run/systemd/generator/cron-tmick-tmick-0.sh. I guess you can use journalctl to get additional info about it. And also you can try to execute it manually to see what's going on. But what you posted is not enough to go further.
 
Old 11-08-2022, 05:19 AM   #6
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,702

Rep: Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895
True, but doesn't systemd cron generater create the files from an actual regular cron job?
But yes cron-tmick-tmick-0.sh does need to be verified.
 
Old 11-08-2022, 04:57 PM   #7
tmick
Member
 
Registered: Jun 2005
Location: North Dakota
Distribution: Debian Testing
Posts: 247

Original Poster
Rep: Reputation: 20
So I ran the command
Code:
/usr/bin/clamscan --exclude-dir=/home/tmick/.clamtk/viruses --exclude-dir=smb4k --exclude-dir=/run/user/tmick/gvfs --exclude-dir=/home/tmick/.gvfs --exclude-dir=.thunderbird --exclude-dir=.mozilla-thunderbird --exclude-dir=.evolution --exclude-dir=Mail --exclude-dir=kmail -i --detect-pua -r /home/tmick --log="$HOME/.clamtk/history/$(date +\%%b-\%%d-\%%Y).log" 2>/dev/null # clamtk-scan"
from a terminal (yes, I should of thought of that a long time ago) and it runs fine. I'm going to try launching the script next (after clam completes the scan) and see if it errors out.
 
Old 11-08-2022, 05:22 PM   #8
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,702

Rep: Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895
Can you post the script?
 
Old 11-08-2022, 05:34 PM   #9
tmick
Member
 
Registered: Jun 2005
Location: North Dakota
Distribution: Debian Testing
Posts: 247

Original Poster
Rep: Reputation: 20
Unhappy

Quote:
Originally Posted by michaelk View Post
Can you post the script?
Great question, let's see if it works.

Code:
/usr/bin/clamscan --exclude-dir=/home/tmick/.clamtk/viruses --exclude-dir=smb4k --exclude-dir=/run/user/tmick/gvfs --exclude-dir=/home/tmick/.gvfs --exclude-dir=.thunderbird --exclude-dir=.mozilla-thunderbird --exclude-dir=.evolution --exclude-dir=Mail --exclude-dir=kmail -i --detect-pua -r /home/tmick --log="$HOME/.clamtk/history/$(date +\%b-\%d-\%Y).log" 2>/dev/null # clamtk-scan
So it appears the script is just the command I just ran. However there are two other related files: cron-tmick-tmick-0.service and cron-tmick-tmick-0.timer.
From cron-tmick-tmick-0.service
Code:
[Unit]
Description=[Cron] "59 23 * * * /usr/bin/clamscan --exclude-dir=/home/tmick/.clamtk/viruses --exclude-dir=smb4k --exclude-dir=/run/user/tmick/gvfs --exclude-dir=/home/tmick/.gvfs --exclude-dir=.thunderbird --exclude-dir=.mozilla-thunderbird --exclude-dir=.evolution --exclude-dir=Mail --exclude-dir=kmail -i --detect-pua -r /home/tmick --log="$HOME/.clamtk/history/$(date +\%%b-\%%d-\%%Y).log" 2>/dev/null # clamtk-scan"
Documentation=man:systemd-crontab-generator(8)
SourcePath=/var/spool/cron/crontabs/tmick
OnFailure=cron-failure@%i.service
Requires=systemd-user-sessions.service
RequiresMountsFor=/home/tmick

[Service]
Type=oneshot
IgnoreSIGPIPE=false
KillMode=process
ExecStart=/bin/sh /run/systemd/generator/cron-tmick-tmick-0.sh
User=tmick
and from the .timer file
Code:
[Unit]
Description=[Timer] "59 23 * * * /usr/bin/clamscan --exclude-dir=/home/tmick/.clamtk/viruses --exclude-dir=smb4k --exclude-dir=/run/user/tmick/gvfs --exclude-dir=/home/tmick/.gvfs --exclude-dir=.thunderbird --exclude-dir=.mozilla-thunderbird --exclude-dir=.evolution --exclude-dir=Mail --exclude-dir=kmail -i --detect-pua -r /home/tmick --log="$HOME/.clamtk/history/$(date +\%%b-\%%d-\%%Y).log" 2>/dev/null # clamtk-scan"
Documentation=man:systemd-crontab-generator(8)
PartOf=cron.target
SourcePath=/var/spool/cron/crontabs/tmick

[Timer]
Unit=cron-tmick-tmick-0.service
OnCalendar=*-*-* 23:59:00
Don't know if that helps??

Last edited by tmick; 11-08-2022 at 05:46 PM. Reason: Script didn't upload, trying to post in reply
 
Old 11-08-2022, 05:51 PM   #10
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,702

Rep: Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895
Is this the script you are referring too.
/run/systemd/generator/cron-tmick-tmick-0.sh

And it is identical to the actual cron job?

Last edited by michaelk; 11-08-2022 at 05:52 PM.
 
Old 11-08-2022, 06:02 PM   #11
tmick
Member
 
Registered: Jun 2005
Location: North Dakota
Distribution: Debian Testing
Posts: 247

Original Poster
Rep: Reputation: 20
Yes, I pasted the text from the cron-tmick-tmick-0.sh
The other two I posted was from the cron-tmick-tmick-0.service and cron-tmick-tmick-0.timer files in /run/systemd/generator/
I did notice a extra space in the path for
Code:
ExecStart=/bin/sh /run/systemd/generator/cron-tmick-tmick-0.sh
after 'sh' I'm unsure if it matters.
 
Old 11-09-2022, 12:48 AM   #12
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,843

Rep: Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309
Quote:
Originally Posted by tmick View Post
Yes, I pasted the text from the cron-tmick-tmick-0.sh
The other two I posted was from the cron-tmick-tmick-0.service and cron-tmick-tmick-0.timer files in /run/systemd/generator/
I did notice a extra space in the path for
Code:
ExecStart=/bin/sh /run/systemd/generator/cron-tmick-tmick-0.sh
after 'sh' I'm unsure if it matters.
that space is required, /bin/sh is the shell interpreter to run your script, which is actually /run/systemd/generator/cron-tmick-tmick-0.sh
But I'm not really sure that path is valid, your script cannot be located inside /run (at least I think).
 
1 members found this post helpful.
Old 11-09-2022, 07:34 AM   #13
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,702

Rep: Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895
I don't see anything obvious and if the scan seems to work I may not worry about it to much. You can always create a separate timer from cron to run your own script as an alternative.

Since bookworm is for testing I might check the bug tracking system to see if there are any for systemd-cron. You can also send in a bug report.

I assume that systemd-cron generator creates a new script at boot time in /run but

I might have to install bookworm in a VM to play with it.
 
Old 11-09-2022, 02:39 PM   #14
tmick
Member
 
Registered: Jun 2005
Location: North Dakota
Distribution: Debian Testing
Posts: 247

Original Poster
Rep: Reputation: 20
Well the path is valid, I can follow it to the shell script in the /run directory.
I've looked for and filed a bug report for this, it just hasn't had much in the response department.
I'm not sure if it is working. If I go into /home/tmick/.clamtk/history the last file is dated Sept 30,2022.
/var/log/clamav and /var/log/apt-cron don't have any errors and Journald / dmesg doesn't show anything either.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Strange Cron directories: /var/spool/cron/cron.GfqqGO Woodsman Slackware 4 05-11-2011 02:37 PM
cron.hourly cron.weekly cron.monthly and 0anacron. Are they necessary? glore2002 Debian 2 09-30-2009 08:57 PM
adding a perl script to cron.daily / cron.d to setup a cron job CrontabNewBIE Linux - Software 6 01-14-2008 08:16 AM
cron not working from crontab nor form /etc/cron/cron.d. What did SuSE change? JZL240I-U SUSE / openSUSE 11 01-04-2007 01:57 AM
Can any one plz explain why/what for cron.d, cron.daily, cron.weekly etc are there. mavinashbabu Linux - Newbie 4 09-21-2006 01:50 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian

All times are GMT -5. The time now is 12:08 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration