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

Notices


Reply
  Search this Thread
Old 07-20-2023, 07:54 AM   #1
JinxsDad
Member
 
Registered: Apr 2023
Location: Fort Walton Beach, FL
Distribution: Slackwareb15
Posts: 271

Rep: Reputation: 23
Major problems with crond and cron


Two issues here, both related to cron.

First, crond keeps crashing after working for a while (until now). If anyone knows of a problem with the normal Slackware 15 crond, please let me know.

Second, last night, I restarted crond a few minutes before 0200, when it was supposed to run this from root's crontab:

0 2 * * * /usr/bin/calendar -a

When, as root, I ran calendar -a, it worked fine.

0200 came and went, no email sent about a calendar entry for a medical appointment today (that I'd forgotten about, and didn't get the labs done for because cron didn't send me the reminder to do those. I also missed an important injection (B-12). I use calendar(5) and /usr/bin/calendar to keep track of medical stuff that my post-cancer #1 memory does a terrible job of remembering. I need cron to be working flawlessly.

Does anyone know of any existing problems with the standard Slackware 15
crond and cron? Or, is there a better version (perhaps from the GNU
archives, etc.)?

Thanks.
 
Old 07-20-2023, 08:41 AM   #2
ozanbaba
Member
 
Registered: May 2003
Location: İzmir
Distribution: Slackware64 15.0 Multilib
Posts: 778

Rep: Reputation: 135Reputation: 135
Can you post crash report of crond? dmesg can help you with that.
Also slackbuilds.org has couple of crond replacements.
 
Old 07-20-2023, 09:30 AM   #3
thinknix
Member
 
Registered: Nov 2008
Distribution: Lots!
Posts: 178

Rep: Reputation: 58
Cron is generally pretty stable, I don't know of any problems with it on Slack 15 in particular (although Slackware does not use cronie like a lot of other distros, but dcron).

However, you mentioned that the command runs outside of cron but not from within it, and I've seen that before. It happens because the environment that the cron command runs in is limited, and will not be the same as when you run a command interactively from a shell. The workaround is to put your command in a wrapper shell script that sets all the proper environment vars it needs, and run the wrapper script via cron. You can also install system/cronie from slackbuilds.org, which allows you to set environment variables in the crontab itself.

If you are curious about the cron environment, put the printenv command in your cron, and redirect the output to a temp file you can look at.
 
Old 07-20-2023, 01:05 PM   #4
jayjwa
Member
 
Registered: Jul 2003
Location: NY
Distribution: Slackware, Termux
Posts: 786

Rep: Reputation: 250Reputation: 250Reputation: 250
I like fcron alot better. The syntax makes more sense. You can have seperate crontabs for users, root, and the system itself.

http://fcron.free.fr/

Code:
fcrontab -l -u systab

## System Wide Crontab 
##
## This file defines a number of jobs for the cron daemon to do that pretain to 
## the system as a whole. Most all of the non-personal system-level things are
## to be kept in this file for simple, one-place organization. 
##
## NOTE: MAKE SURE THIS FILE AND FCRON'S INTERNAL COPY SYNC!!
## (Or funny, unexpected things might happen)

# No mail for any of these by default, but definately report
# if the command wasn't run for some reason
!mail(false),noticenotrun(true),nice(18)

# Enter a "Restart" mark in the logfile for sadc and make sure that
# logfile is created just after midnight each day so that the 'sar'
# command with always produce output instead of 'file not found' 
& 1 0 * * * /usr/lib64/sa/sadc -

# Generate a summary of process accounting each midnight 
# This is only the report generation, and is still needed.
%nightly * 23 /usr/lib64/sa/sa2 -A

# Keep DB for nsswitch usage up to date with /etc/ files
%nightly * 23 make -C /var/db

# Update the man page data base for new pages.
# Command for mandb 'man'
%middaily * 12-13 mandb -q

# makewhatis for regular 'man'
#%middaily * 12-13 /usr/sbin/makewhatis -s '0p 1p 3p 1 2 3 4 5 6 7 8 9 n' -w

# Run updatedb daily, too. This is for the "locate" command.
# It's database is at /var/lib/mlocate/mlocate.db
%nightly * 4-5 /usr/bin/updatedb --prunepaths="/tmp /sys /var/tmp /proc /dev /root /mnt /lost+found /home /run /media" 

# Logrotate. Rotate old logs each night
%nightly * 5-6 /usr/sbin/logrotate /etc/logrotate.conf

# UUCP. Have the daemon check for any queued jobs/mail/news to be sent.
# Check for work for system "atr2". Only startup if work to do.
#%hourly * /usr/sbin/uucico --system atr2 --ifwork --quiet

# Scan the system font dirs nightly to keep cache fresh
%nightly * 4-5 fc-cache -r -s /usr/share/fonts/OTF /usr/share/fonts/TTF

## Complex Fixed System Jobs
##
## These jobs run as one-shot jobs from the /etc/cron.d directory
## and only appear in the system crontab. Most of these tasks are 
## implemented as scripts that do a task involving many lines of 
## code that can't well be written as a normal fcron job
##
%nightly * 2-3 /usr/bin/run-parts /etc/cron.d

## EOF
Logs look like so:
Code:
Jul 19 05:00:01 atr2 fcron[20729]: Job '/usr/sbin/logrotate /etc/logrotate.conf' completed
Jul 19 12:00:00 atr2 fcron[945]: Job 'mandb -q' started for user systab (pid 946)
Jul 19 12:00:04 atr2 fcron[945]: Job 'mandb -q' completed
Jul 19 23:00:00 atr2 fcron[27746]: Job 'make -C /var/db' started for user systab (pid 27747)
Jul 19 23:00:00 atr2 fcron[27748]: Job '/usr/lib64/sa/sa2 -A' started for user systab (pid 27749)
Jul 19 23:00:00 atr2 fcron[27746]: Job 'make -C /var/db' completed
Jul 19 23:00:00 atr2 fcron[27748]: Job '/usr/lib64/sa/sa2 -A' completed
Jul 20 00:01:00 atr2 fcron[30577]: Job '/usr/lib64/sa/sadc -' started for user systab (pid 30578)
Jul 20 00:01:00 atr2 fcron[30577]: Job '/usr/lib64/sa/sadc -' completed
Jul 20 02:00:00 atr2 fcron[3823]: Job '/usr/bin/run-parts /etc/cron.d' started for user systab (pid 3824)
Jul 20 02:00:00 atr2 run-parts[3824]: (/etc/cron.d) starting certwatch
Jul 20 02:00:00 atr2 run-parts[3824]: (/etc/cron.d) finished certwatch
Jul 20 02:00:00 atr2 fcron[3823]: Job '/usr/bin/run-parts /etc/cron.d' completed
Jul 20 04:00:00 atr2 fcron[8027]: Job 'fc-cache -r -s /usr/share/fonts/OTF /usr/share/fonts/TTF' started for user systab (pid 8028)
Jul 20 04:00:00 atr2 fcron[8029]: Job '/usr/bin/updatedb --prunepaths="/tmp /sys /var/tmp /proc /dev /root /mnt /lost+found /home /run /media"' started for user systab (pid 8030)
Jul 20 04:00:01 atr2 fcron[8027]: Job 'fc-cache -r -s /usr/share/fonts/OTF /usr/share/fonts/TTF' completed
Jul 20 04:00:03 atr2 fcron[8029]: Job '/usr/bin/updatedb --prunepaths="/tmp /sys /var/tmp /proc /dev /root /mnt /lost+found /home /run /media"' completed
Jul 20 05:00:00 atr2 fcron[9970]: Job '/usr/sbin/logrotate /etc/logrotate.conf' started for user systab (pid 9971)
 
1 members found this post helpful.
Old 07-20-2023, 05:28 PM   #5
metaed
Member
 
Registered: Apr 2022
Location: US
Distribution: Slackware64 15.0
Posts: 366

Rep: Reputation: 171Reputation: 171
As a workaround, you could move the crond startup to inittab. This has the advantage that inittab can respawn it should it die.
 
Old 07-20-2023, 06:30 PM   #6
jmccue
Member
 
Registered: Nov 2008
Location: US
Distribution: slackware
Posts: 697
Blog Entries: 1

Rep: Reputation: 381Reputation: 381Reputation: 381Reputation: 381
Quote:
Originally Posted by JinxsDad View Post
Two issues here, both related to cron.
0 2 * * * /usr/bin/calendar -a
calendar is not part of Slackware, is that from slackbuilds or another place ?

Anyway you can try this:

1. stop cron using rc.crond
2. Modify file /etc/default/crond, set to CROND_OPTS "info"
3. start cron using rc.crond

Check log file /var/log/cron for messages. Maybe that will give you an idea of what is happening.
 
Old 07-21-2023, 05:26 AM   #7
ozanbaba
Member
 
Registered: May 2003
Location: İzmir
Distribution: Slackware64 15.0 Multilib
Posts: 778

Rep: Reputation: 135Reputation: 135
thinknix remained me of a trick. Not really a trick but probably calendar is not in the PATH of crond so you should use full path to it.
That goes to everything you can in crond. It's better to use full path instead of just application name.
 
Old 07-26-2023, 03:20 PM   #8
tmmukunn
Member
 
Registered: Nov 2007
Distribution: Slackware
Posts: 43

Rep: Reputation: 9
I've used the default crontab with not too much problems. In my case, I just put stuff in /etc/cron.hourly or /etc/cron.weekly and cron picks it up (crontab -l shows how its setup).

was there anything in /var/log/cron?
 
Old 07-27-2023, 08:51 PM   #9
rkelsen
Senior Member
 
Registered: Sep 2004
Distribution: slackware
Posts: 4,461
Blog Entries: 7

Rep: Reputation: 2561Reputation: 2561Reputation: 2561Reputation: 2561Reputation: 2561Reputation: 2561Reputation: 2561Reputation: 2561Reputation: 2561Reputation: 2561Reputation: 2561
Quote:
Originally Posted by JinxsDad View Post
Does anyone know of any existing problems with the standard Slackware 15 crond and cron?
Nope. It's been bulletproof here... running 24x7 without any issues at all since 15.0 was released.

Quote:
Originally Posted by tmmukunn View Post
I've used the default crontab with not too much problems. In my case, I just put stuff in /etc/cron.hourly or /etc/cron.weekly and cron picks it up (crontab -l shows how its setup).
Yeah, same here. I've found the default cron configuration to be excellent.

For things which I want to run at specific times, I use "at," which is running by default on a full/default installation of Slackware.

As an example: I have a script under /etc/cron.daily called "redundant" which makes a redundant copy of my files at 6:00pm every day.

The content of my /etc/cron.daily/redundant script is:
Code:
#!/bin/sh
echo "rsync -av -H --delete /path/to/myfiles /path/to/redundant_copy" | at 6:00pm
That's it. No need to edit crontab or restart cron. As I said above, it has been running flawlessly for almost 18 months. At 4:40am when cron runs its daily jobs, this job gets scheduled for 6:00pm and then runs at 6:00pm without any issues.

Notes:
- Of course, the script /etc/cron.daily/redundant has to be executable.
- To stop it from running, you can simply remove the execute bit, eg: "# chmod -x /etc/cron.daily/redundant"
- You have to pipe the command to at, using the echo statement as shown. Any command you want to run should go in between the quote marks.
- You can change the time to whatever you like. It'll be scheduled at 4:40am when cron runs the scripts under /etc/cron.daily/. You can verify that the job has been scheduled with "atq".

Last edited by rkelsen; 07-27-2023 at 11:06 PM.
 
1 members found this post helpful.
Old 07-28-2023, 01:05 AM   #10
elcore
Senior Member
 
Registered: Sep 2014
Distribution: Slackware
Posts: 1,754

Rep: Reputation: Disabled
Quote:
Originally Posted by JinxsDad View Post
Does anyone know of any existing problems with the standard Slackware 15
crond and cron?
No major problems at all, but FWIW; it needs to use 'mktemp' as apparently /tmp or tmpfs is not good enough.
Got rid of it last year because of that small issue, I usually don't want random programs make tempdirs on my systems for security reasons.

Quote:
Originally Posted by JinxsDad View Post
I need cron to be working flawlessly.
Not me, I can manage just fine without it.
 
Old 07-28-2023, 03:38 AM   #11
henca
Member
 
Registered: Aug 2007
Location: Linköping, Sweden
Distribution: Slackware
Posts: 977

Rep: Reputation: 665Reputation: 665Reputation: 665Reputation: 665Reputation: 665Reputation: 665
Quote:
Originally Posted by rkelsen View Post
Nope. It's been bulletproof here... running 24x7 without any issues at all since 15.0 was released.
I agree that cron works great in Slackware 15 and earlier versions of Slackware.

Quote:
Originally Posted by rkelsen View Post
For things which I want to run at specific times, I use "at," which is running by default on a full/default installation of Slackware.
Doing so would be possible, but I prefer to:
  1. crontab -l > /tmp/crontab.txt
  2. (edit the file /tmp/crontab.txt, add what you want to do at specific times)
  3. crontab /tmp/crontab.txt

See the man page of crontab for the syntax of the file. The above can be done both for root and for normal users. Instead of saving the crontab contents to a temporary file you might want to save it on some persistent, backed up storage to easily be able to recreate it on another installation.

regards Henrik
 
Old 07-28-2023, 03:49 AM   #12
rkelsen
Senior Member
 
Registered: Sep 2004
Distribution: slackware
Posts: 4,461
Blog Entries: 7

Rep: Reputation: 2561Reputation: 2561Reputation: 2561Reputation: 2561Reputation: 2561Reputation: 2561Reputation: 2561Reputation: 2561Reputation: 2561Reputation: 2561Reputation: 2561
Quote:
Originally Posted by henca View Post
Doing so would be possible
Not "would be" ... "is"!

The benefit of using a drop-in script is that it simplifies re-deployment. Just drop the script in, and it works without having to edit anything.
 
Old 07-28-2023, 05:18 AM   #13
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,901

Rep: Reputation: 5025Reputation: 5025Reputation: 5025Reputation: 5025Reputation: 5025Reputation: 5025Reputation: 5025Reputation: 5025Reputation: 5025Reputation: 5025Reputation: 5025
Involving both cron and at in the scheduling of the same job seems both redundant and fragile to me, but each to his own.

If you don't want to edit crontabs then why not just stick a script in cron.hourly/ that checks the hour is 18 before doing anything? Seems far less involved than getting 'at' in the picture.


Back on topic:
Not encountered any issues with crond on slackware 15.0.
at-3.2.4 was broken, but Pat backed that one out.
at-3.2.5 is "fixed" but I don't like how the developer fixed it (which I've talked about in another thread).

Last edited by GazL; 07-28-2023 at 05:36 AM.
 
Old 07-28-2023, 07:50 PM   #14
rkelsen
Senior Member
 
Registered: Sep 2004
Distribution: slackware
Posts: 4,461
Blog Entries: 7

Rep: Reputation: 2561Reputation: 2561Reputation: 2561Reputation: 2561Reputation: 2561Reputation: 2561Reputation: 2561Reputation: 2561Reputation: 2561Reputation: 2561Reputation: 2561
Quote:
Originally Posted by GazL View Post
Involving both cron and at in the scheduling of the same job seems both redundant and fragile to me,
It's not fragile at all. As I said, it hasn't missed a beat in almost 18 months of 24x7 operation. Simply leveraging the at daemon which is installed and running by default on a stock installation of Slackware.
Quote:
Originally Posted by GazL View Post
If you don't want to edit crontabs then why not just stick a script in cron.hourly/ that checks the hour is 18 before doing anything? Seems far less involved than getting 'at' in the picture.
Involved? It's a one liner... Which you can drop in, package, and turn on and off at will. It also gives the flexibility to choose the exact minute you want the command to run.

Your proposed idea is not bad, but runs every hour instead of once per day, doesn't allow you to easily choose the exact minute to run a command, and requires more than a simple one liner. I'm not a programmer and so I struggle with regex.
Quote:
Originally Posted by GazL View Post
but each to his own.
Indeed.
 
Old 07-29-2023, 02:36 AM   #15
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,901

Rep: Reputation: 5025Reputation: 5025Reputation: 5025Reputation: 5025Reputation: 5025Reputation: 5025Reputation: 5025Reputation: 5025Reputation: 5025Reputation: 5025Reputation: 5025
By "fragility" I mean that with your approach there are a number of scenarios where downtime could result in your job not being run, being scheduled twice for the same date/time, or being run at the wrong time.

If you're happy that your box will be up 24/7 and these risks don't concern you, then that's fine, but this approach is inherently fragile and one would be better off just adding a 18:00 cron entry.
 
  


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
pam_access(crond:account): access denied for user `root' from `cron' newbie14 Linux - Security 1 04-08-2018 03:35 AM
[SOLVED] if i modify and/or remove files in /etc/cron.daily, do i need to restart crond? sneakyimp Linux - Newbie 2 10-20-2012 04:13 PM
/sbin/service crond unable to start - gives permission error on /usr/sbin/crond mgervacio Linux - Newbie 6 07-16-2008 01:03 PM
cron spawning extra crond - script fails jbob75 Linux - Software 2 11-21-2005 04:29 AM
Crond Dead But Subsys Locked, cannot restart cron services jmm8142 Linux - Software 4 05-23-2005 12:41 PM

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

All times are GMT -5. The time now is 05:28 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