Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
a few Cron questions..!
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
ferg
Guru
Guru


Joined: 15 Nov 2002
Posts: 536
Location: Cambridge, UK

PostPosted: Mon Dec 03, 2018 10:51 am    Post subject: a few Cron questions..! Reply with quote

I'm struggling with some cron issues and I wanted to clarify a few things. Excuse me if these are obvious!

(1) What is the recommended Cron for Gentoo? I'm running Vixie-cron, which I installed quite some years ago. I note there's a "Cronie" fork of Vixie-Cron. Should I be using this?

(2) For the root user there is a "/etc/crontab" and a separate file accessed by typing "crontab -e". Which of these two files should environment variables (such as MAILTO and MAILFROM") go? I assume for system wide defaults they need to go in /etc/crontab?

(3) If the aforementioned environment variables are defined for root, then they do not need to be redefined in each users crontab, right? That is unless you want to override the system defaults

Thanks a bundle!

Cheers,
Ferg
_________________
Climb up it, kayak down it + make sure it runs on GNU/Linux
"cease to exist, giving my goodbye, drive my car into the ocean,
you think I'm dead, but i sail away, on a wave of mutilation!"
Back to top
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 9656
Location: almost Mile High in the USA

PostPosted: Mon Dec 03, 2018 7:48 pm    Post subject: Reply with quote

1. Up to you if you want to go to cronie. People don't like unmaintained software, but sometimes software does not need to be maintained as it's stable.
2. /etc/crontab is the "system" crontab for system jobs.
/var/spool/cron/crontabs/root is for the "root user" . They are separate but both have the same effective user id. Jobs submitted from one or the other have their own environment. You could have one mailed to one and the other mailed to another account instead of the default having both sent to root. You'll need to set them individually if you don't want each to go to root's mail.
3. Each user have their own mail account...?? They should go to each individual users' mail by default. Question doesn't make sense...??
_________________
Intel Core i7 2700K/Radeon R7 250/24GB DDR3/256GB SSD
What am I supposed watching?
Back to top
View user's profile Send private message
Anon-E-moose
Watchman
Watchman


Joined: 23 May 2008
Posts: 6095
Location: Dallas area

PostPosted: Mon Dec 03, 2018 8:02 pm    Post subject: Reply with quote

I've used vixie-cron for years, zero problems. YMMV

Env vars can be set for each users crontab, at the top of it, look at files in /usr/share/doc/vixie-cron-4.1-r15/ (or whatever version you have)
_________________
PRIME x570-pro, 3700x, 6.1 zen kernel
gcc 13, profile 17.0 (custom bare multilib), openrc, wayland
Back to top
View user's profile Send private message
Ant P.
Watchman
Watchman


Joined: 18 Apr 2009
Posts: 6920

PostPosted: Tue Dec 04, 2018 12:40 am    Post subject: Reply with quote

I switched all my systems to cronie recently. It works exactly the same as vixie-cron except it's slightly more efficient (uses inotify instead of polling for crontab changes, daily/etc jobs can be randomised instead of causing a stampeding herd every day across all machines)
Back to top
View user's profile Send private message
Fitzcarraldo
Advocate
Advocate


Joined: 30 Aug 2008
Posts: 2034
Location: United Kingdom

PostPosted: Tue Dec 04, 2018 1:39 am    Post subject: Reply with quote

I've had trouble* with vixie-cron, so I don't use it anymore.

* I use the bookmarks manager Buku on three Linux machines to sync with a single bookmarks database residing on a Cloud server. Each of the machines also runs a cron job to create a text file of the database output also on the Cloud server, just in case I happen to be using a machine that is not running Buku (e.g. a Windows machine or a smartphone). The three Linux machines were originally using the cronie, cron, and vixie-cron daemons, respectively. However, I found that the text file on the machine running vixie-cron was always truncated. It appeared that somehow vixie-cron was not waiting for the Buku print command in the cron job to finish. So I stopped and disabled the vixie-cron daemon on that machine, uninstalled vixie-cron, installed cronie, enabled and started the cronie service, and everything now works fine. So I will avoid using vixie-cron in any future installations.
_________________
Clevo W230SS: amd64, VIDEO_CARDS="intel modesetting nvidia".
Compal NBLB2: ~amd64, xf86-video-ati. Dual boot Win 7 Pro 64-bit.
OpenRC udev elogind & KDE on both.

Fitzcarraldo's blog
Back to top
View user's profile Send private message
ferg
Guru
Guru


Joined: 15 Nov 2002
Posts: 536
Location: Cambridge, UK

PostPosted: Tue Dec 04, 2018 9:55 am    Post subject: Reply with quote

eccerr0r wrote:
1. Up to you if you want to go to cronie. People don't like unmaintained software, but sometimes software does not need to be maintained as it's stable.
2. /etc/crontab is the "system" crontab for system jobs.
/var/spool/cron/crontabs/root is for the "root user" . They are separate but both have the same effective user id. Jobs submitted from one or the other have their own environment. You could have one mailed to one and the other mailed to another account instead of the default having both sent to root. You'll need to set them individually if you don't want each to go to root's mail.
3. Each user have their own mail account...?? They should go to each individual users' mail by default. Question doesn't make sense...??


Thank you. That's clear.

For [3] i was talking about variables such as "MAILTO" and "MAILFROM" rather than local email delivery. Are these propagated from the system crontab to user crontab or not?

Thanks.
_________________
Climb up it, kayak down it + make sure it runs on GNU/Linux
"cease to exist, giving my goodbye, drive my car into the ocean,
you think I'm dead, but i sail away, on a wave of mutilation!"
Back to top
View user's profile Send private message
ferg
Guru
Guru


Joined: 15 Nov 2002
Posts: 536
Location: Cambridge, UK

PostPosted: Tue Dec 04, 2018 10:01 am    Post subject: Reply with quote

Anon-E-moose wrote:
I've used vixie-cron for years, zero problems. YMMV

Env vars can be set for each users crontab, at the top of it, look at files in /usr/share/doc/vixie-cron-4.1-r15/ (or whatever version you have)


Thanks!
_________________
Climb up it, kayak down it + make sure it runs on GNU/Linux
"cease to exist, giving my goodbye, drive my car into the ocean,
you think I'm dead, but i sail away, on a wave of mutilation!"
Back to top
View user's profile Send private message
Anon-E-moose
Watchman
Watchman


Joined: 23 May 2008
Posts: 6095
Location: Dallas area

PostPosted: Tue Dec 04, 2018 11:03 am    Post subject: Reply with quote

If cronie is a spin-off of vixie-cron it probably works the same with variables.
_________________
PRIME x570-pro, 3700x, 6.1 zen kernel
gcc 13, profile 17.0 (custom bare multilib), openrc, wayland
Back to top
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 9656
Location: almost Mile High in the USA

PostPosted: Tue Dec 04, 2018 4:25 pm    Post subject: Reply with quote

I would imagine just like any Un*x program, the standard is for environment to be passed to each invocation (i.e. crontab) and each invocation will otherwise have its own environment that's not shared with the others.

Perhaps this quote may make things clearer?

vixie-cron manpage wrote:
In addition to LOGNAME, HOME, and SHELL, cron(8) will look at MAILTO if
it has any reason to send mail as a result of running commands in
``this'' crontab. If MAILTO is defined (and non-empty), mail is sent
to the user so named. If MAILTO is defined but empty (MAILTO=""), no
mail will be sent. Otherwise mail is sent to the owner of the crontab.
This option is useful if you decide on /bin/mail instead of
/usr/lib/sendmail as your mailer when you install cron -- /bin/mail
doesn't do aliasing, and UUCP usually doesn't read its mail.

_________________
Intel Core i7 2700K/Radeon R7 250/24GB DDR3/256GB SSD
What am I supposed watching?
Back to top
View user's profile Send private message
ferg
Guru
Guru


Joined: 15 Nov 2002
Posts: 536
Location: Cambridge, UK

PostPosted: Wed Dec 05, 2018 1:29 pm    Post subject: Reply with quote

Thanks.

Is MAILFROM used by VixieCron? I cannot find it in the man page nor documentation.
_________________
Climb up it, kayak down it + make sure it runs on GNU/Linux
"cease to exist, giving my goodbye, drive my car into the ocean,
you think I'm dead, but i sail away, on a wave of mutilation!"
Back to top
View user's profile Send private message
cboldt
Veteran
Veteran


Joined: 24 Aug 2005
Posts: 1046

PostPosted: Thu Dec 06, 2018 11:00 am    Post subject: Reply with quote

For vixie-cron ....

MAILTO in the environment is recognized, and can be set in /etc/crontab or user crontabs.

See `man 5 crontab`

"Man" tip, you can see all the manpages for "command" with `man -a command` - the use of MAILTO does not show in `man crontab` as that view is of the crontab(1) manpage.

Edit to add ... I searched the vixie-cron source code for instances of the strings "MAILTO" and "MAILFROM". There are no instances of MAILFROM. config.h defines a MAILFMT variable used during compiling. MAILFMT is set as "%s -FCronDaemon -odi -oem -oi -"

The instances of env_get in the source code refer to PATH, HOME, SHELL, MAILTO and nothing else.


Last edited by cboldt on Thu Dec 06, 2018 11:18 am; edited 1 time in total
Back to top
View user's profile Send private message
ferg
Guru
Guru


Joined: 15 Nov 2002
Posts: 536
Location: Cambridge, UK

PostPosted: Thu Dec 06, 2018 11:12 am    Post subject: Reply with quote

cboldt wrote:
For vixie-cron ....

MAILTO in the environment is recognized, and can be set in /etc/crontab or user crontabs.

See `man 5 crontab`

"Man" tip, you can see all the manpages for "command" with `man -a command` - the use of MAILTO does not show in `man crontab` as that view is of the crontab(1) manpage.


So no MAILFROM then!
_________________
Climb up it, kayak down it + make sure it runs on GNU/Linux
"cease to exist, giving my goodbye, drive my car into the ocean,
you think I'm dead, but i sail away, on a wave of mutilation!"
Back to top
View user's profile Send private message
cboldt
Veteran
Veteran


Joined: 24 Aug 2005
Posts: 1046

PostPosted: Thu Dec 06, 2018 11:20 am    Post subject: Reply with quote

Nope, no MAILFROM. You'd have to alter the source code to get access to the "From" line in the email header.

Edit to answer another question. You asked if environment entries in /etc/crpontab were propagated to user crontabs. No, they are not. vixie-cron picks up a few pieces of the environment of the invoking USER, and only of the invoking USER.
Back to top
View user's profile Send private message
ferg
Guru
Guru


Joined: 15 Nov 2002
Posts: 536
Location: Cambridge, UK

PostPosted: Thu Dec 06, 2018 11:40 am    Post subject: Reply with quote

cboldt wrote:
Nope, no MAILFROM. You'd have to alter the source code to get access to the "From" line in the email header.

Edit to answer another question. You asked if environment entries in /etc/crpontab were propagated to user crontabs. No, they are not. vixie-cron picks up a few pieces of the environment of the invoking USER, and only of the invoking USER.


Thanks a lot.
_________________
Climb up it, kayak down it + make sure it runs on GNU/Linux
"cease to exist, giving my goodbye, drive my car into the ocean,
you think I'm dead, but i sail away, on a wave of mutilation!"
Back to top
View user's profile Send private message
Anon-E-moose
Watchman
Watchman


Joined: 23 May 2008
Posts: 6095
Location: Dallas area

PostPosted: Thu Dec 06, 2018 11:59 am    Post subject: Reply with quote

I would think MAILFROM would get automatically picked up as the crontab user name (not changeable it seems)

Edit to add: when I get mail from other servers on my network they come with the From line as <user>@<domain name> if on same box it just says <user>

Should be simple enough to set up a test and see what it does, both adding a MAILFROM env variable and without to see what is displayed.
_________________
PRIME x570-pro, 3700x, 6.1 zen kernel
gcc 13, profile 17.0 (custom bare multilib), openrc, wayland
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum