The officially official Devuan Forum!

You are not logged in.

#1 2023-07-06 09:13:05

SpongeBOB
Member
From: Brussels
Registered: 2022-02-07
Posts: 113  

[SOLVED] is cron daemon crond is running when there is no cronjob set ?

Hi everyone,

I would like to create a cronjob.

I've found a "tutorial" online -->  https://linuxhandbook.com/crontab/#the-cron-daemon

But it's start already weirdly...

on his example

christopher@pop-os:~$ ps ux | grep crond
christo+  8942  0.0  0.0  18612   840 pts/0    S+   02:16   0:00 grep --color=auto crond

I can see that the daemon is running for my user account.

neutral for me it's look like that we see the grep process ! not the crond !? Am I right?

anyway I've tried on my Devuan(Chimaera) and I don't see a crond running.. is that normal ?

Thanks.


Linux noob, plz be kind big_smile

Offline

#2 2023-07-06 10:25:42

alexkemp
Member
Registered: 2018-05-14
Posts: 338  

Re: [SOLVED] is cron daemon crond is running when there is no cronjob set ?

SpongeBOB wrote:

it's look like that we see the grep process ! not the crond !? Am I right?

Correct (I got the exact same result). Cron is NOT running in your system (you have grepped for 'crond', and therefore in the ps listing it shows the full command-line, which includes 'crond'). If Cron *was* running there would be at least 2 ps lines containing 'crond', one for the daemon & one for grep.

Offline

#3 2023-07-06 10:51:13

Andre4freedom
Member
Registered: 2017-11-15
Posts: 172  

Re: [SOLVED] is cron daemon crond is running when there is no cronjob set ?

my 2 cents to it:

andre@kyoto:~$ ps -aef | grep cron
root      2403     1  0 09:45 ?        00:00:00 /usr/sbin/cron
andre    11016 10606  0 12:45 pts/0    00:00:00 grep --color=auto cron
andre@kyoto:~$ 

The daemon is called cron:

andre@kyoto:~$ ls -l /etc/init.d/cron*
-rwxr-xr-x 1 root root 3059 Oct 11  2019 /etc/init.d/cron
andre@kyoto:~$

Devuan 4, Chimaera, up-to-date.

Offline

#4 2023-07-06 13:53:47

alexkemp
Member
Registered: 2018-05-14
Posts: 338  

Re: [SOLVED] is cron daemon crond is running when there is no cronjob set ?

I blame forgetfulness (aka old age):

$ ps aux | grep cron
root      1516  0.0  0.0   8684  3460 ?        Ss   Jul01   0:01 /usr/sbin/cron
alexk     8432  0.0  0.0   6372   712 pts/0    S+   14:52   0:00 grep --color=auto cron

Offline

#5 2023-07-06 15:06:25

boughtonp
Member
From: UK
Registered: 2023-01-19
Posts: 212  
Website

Re: [SOLVED] is cron daemon crond is running when there is no cronjob set ?

On the unasked adjacent question, the common solution to grep appearing in ps|grep output is to alter the pattern so it doesn't match itself, e.g. ps aux | grep 'cro[n]'

Another solution is pgrep.


3.1415P265E589T932E846R64338

Offline

#6 2023-07-07 05:28:07

SpongeBOB
Member
From: Brussels
Registered: 2022-02-07
Posts: 113  

Re: [SOLVED] is cron daemon crond is running when there is no cronjob set ?

Thank you all for your reply !

Thank you that have confirmed my thinking. I'm shocked that some people can post "tutorial" without mastering a bit the topic.... Internet peoples.. big_smile

@boughtonp, oh great indeed I will use also a regex expression in grep to avoid to have the grep itself in the results.

ps aux | grep 'cron$'

Last edited by SpongeBOB (2023-07-07 05:28:49)


Linux noob, plz be kind big_smile

Offline

#7 2023-07-09 18:28:29

aitor
Member
From: basque country
Registered: 2016-12-03
Posts: 230  
Website

Re: [SOLVED] is cron daemon crond is running when there is no cronjob set ?

SpongeBOB wrote:

Thank you all for your reply !

Thank you that have confirmed my thinking. I'm shocked that some people can post "tutorial" without mastering a bit the topic.... Internet peoples.. big_smile

@boughtonp, oh great indeed I will use also a regex expression in grep to avoid to have the grep itself in the results.

ps aux | grep 'cron$'

Another way to avoid the unwanted expression might be using the syntax grep -v "unwanted_regex_expression". Therefore, you can avoid the grep itself as follows:

ps aux | grep "cron" | grep -v " grep "

If you work systematically, things will come by itself (Lev D. Landau)

Offline

#8 2023-07-09 18:56:05

aitor
Member
From: basque country
Registered: 2016-12-03
Posts: 230  
Website

Re: [SOLVED] is cron daemon crond is running when there is no cronjob set ?

aitor wrote:
SpongeBOB wrote:

Thank you all for your reply !

Thank you that have confirmed my thinking. I'm shocked that some people can post "tutorial" without mastering a bit the topic.... Internet peoples.. big_smile

@boughtonp, oh great indeed I will use also a regex expression in grep to avoid to have the grep itself in the results.

ps aux | grep 'cron$'

Another way to avoid the unwanted expression might be using the syntax grep -v "unwanted_regex_expression". Therefore, you can avoid the grep itself as follows:

ps aux | grep "cron" | grep -v " grep "

The line containing the grep command itself is supposed to be printed at the end due to its higher pid -and then it'll be ignored thanks to the use of the regex 'cron$'-, but who knows...


If you work systematically, things will come by itself (Lev D. Landau)

Offline

#9 2023-07-09 21:11:27

boughtonp
Member
From: UK
Registered: 2023-01-19
Posts: 212  
Website

Re: [SOLVED] is cron daemon crond is running when there is no cronjob set ?

Neither appending an end-of-line anchor nor doing a second negative grep are guaranteed "lossless" solutions - they both have potential to exclude valid lines. (Might not be very likely with the latter, but is still possible.)

Wrapping one of the characters in a character class will never exclude anything except the specific unwanted grep line, and is only two extra key presses.

And again, an even better solution is to ensure procps is installed, and use pgrep, which never includes itself in its output and defaults to just the pid; if one needs the extra detail ps provides, ps u $(pgrep cron) will do that.


3.1415P265E589T932E846R64338

Offline

#10 2023-07-29 13:12:01

SpongeBOB
Member
From: Brussels
Registered: 2022-02-07
Posts: 113  

Re: [SOLVED] is cron daemon crond is running when there is no cronjob set ?

Thank you all for your additional inputs !

I've tried pgrep = ♥


Linux noob, plz be kind big_smile

Offline

Board footer