You are not logged in.

#1 2019-01-02 07:19:48

makh
Member
Registered: 2011-10-10
Posts: 299

Cron Job during no login

Hi

I am using cronie.

I tested cvlc to run an audio file. My laptop had just restarted and I hadnt login to my user account. But the croned application didnt run.

Do I have to be logged in, so that applications execute?

Thankyou


OS:  Arch  &/  Debian
System: LENOVO ThinkPad E14
Desktop: Xfce

Offline

#2 2019-01-02 09:28:32

seth
Member
Registered: 2012-09-03
Posts: 49,980

Re: Cron Job during no login

cvlc connects to the session bus, are you sure the job didn't run or did you just not hear music? Try eg. mpg123/ogg123…

Offline

#3 2019-01-02 19:28:47

makh
Member
Registered: 2011-10-10
Posts: 299

Re: Cron Job during no login

Hi

I tried with mpg123.

Please note I dont use the Login Manager, so after startup and no login, I am having tty1 only. Perhaps this is the issue.

Edit 1: It worked with cron of root. But I didnt intended to use the root for playing an audio! I think it is not the correct way. This is not a root's job.

Thankyou

Last edited by makh (2019-01-02 19:37:09)


OS:  Arch  &/  Debian
System: LENOVO ThinkPad E14
Desktop: Xfce

Offline

#4 2019-01-02 20:27:58

seth
Member
Registered: 2012-09-03
Posts: 49,980

Re: Cron Job during no login

Neither needs a display server, nor do you have to be logged in.
It's most likely an issue w/ accessing the audio device, make the call

mpg123 /path/to/music.mp3 > /tmp/mpg123.log 2>&1

Offline

#5 2019-01-03 12:15:56

makh
Member
Registered: 2011-10-10
Posts: 299

Re: Cron Job during no login

Hi

Theres some problem:

cat mpg123.log 
High Performance MPEG 1.0/2.0/2.5 Audio Player for Layers 1, 2 and 3
	version 1.25.10; written and copyright by Michael Hipp and others
	free software (LGPL) without any warranty but with best wishes

Thankyou


OS:  Arch  &/  Debian
System: LENOVO ThinkPad E14
Desktop: Xfce

Offline

#6 2019-01-03 13:22:53

seth
Member
Registered: 2012-09-03
Posts: 49,980

Re: Cron Job during no login

Is that all?
It doesn't look as if any error messages were logged, but at least you know the issue is w/ the playback, not w/ the cronjob.

Try

sudo useradd dummy
sudo -u dummy mpg123 /path/to/music.mp3
sudo userdel dummy # NOT if you actually have a dummy account ;-)

to simulate a playback for a non-active user, you'll likely get some alsa or pulseaudio errors.

Offline

#7 2019-01-03 18:44:00

makh
Member
Registered: 2011-10-10
Posts: 299

Re: Cron Job during no login

Hi
Let me try with the sudo account. It isnt different from the root account.

But it still doesnt make sense...

From your points: I think that as my user session is inactive due to fresh bootup; so the  audio fails to play!

Thankyou


OS:  Arch  &/  Debian
System: LENOVO ThinkPad E14
Desktop: Xfce

Offline

#8 2019-01-03 19:59:40

seth
Member
Registered: 2012-09-03
Posts: 49,980

Re: Cron Job during no login

Nono, the idea is to create a "dummy" user  (with that username ;-) and sudo as that inprivilegued user (-u dummy) to generate some output.
You've to be still logged in to have an active session, but yeah, the idea is that the audio device access struggles at some point - you might be able to adjust a polkit rule for this.

Offline

#9 2019-01-06 08:07:40

makh
Member
Registered: 2011-10-10
Posts: 299

Re: Cron Job during no login

Hi

I didnt use your technique; as I use a sudo user already for some tasks. It is a user apart from my routine user.

Anyhows... sudo user didnt worked! I dont intend to try further as root is doing the task, and I dont want to playing with polkit or other advance configurations.

Thankyou


OS:  Arch  &/  Debian
System: LENOVO ThinkPad E14
Desktop: Xfce

Offline

#10 2019-01-06 08:57:22

seth
Member
Registered: 2012-09-03
Posts: 49,980

Re: Cron Job during no login

There is no "sudo user" and that's not the point at all.
I'm trying to sell you the idea to create an unprivilegued user to use it w/o bein logged in to provoke the same failure in mpg123 to get the required error messages you somehow couldn't generate w/ a cronjob modification so that we can see *why* an inactive user cannot play music so that we can start to figure how to fix that.

Offline

#11 2019-01-06 10:13:56

makh
Member
Registered: 2011-10-10
Posts: 299

Re: Cron Job during no login

Hi

This is without cron:

sudo -u dummy mpg123 /home/path/music.mp3
High Performance MPEG 1.0/2.0/2.5 Audio Player for Layers 1, 2 and 3
	version 1.25.10; written and copyright by Michael Hipp and others
	free software (LGPL) without any warranty but with best wishes
Failed to create secure directory (/home/dummy/.config/pulse): No such file or directory
Failed to create secure directory (/home/dummy/.config/pulse): No such file or directory
Failed to create secure directory (/home/dummy/.config/pulse): No such file or directory
Segmentation fault

Thankyou


OS:  Arch  &/  Debian
System: LENOVO ThinkPad E14
Desktop: Xfce

Offline

#12 2019-01-06 12:52:15

seth
Member
Registered: 2012-09-03
Posts: 49,980

Re: Cron Job during no login

So pulseaudio and that already stumbles on the missing home directory.
Since that won't be the problem w/ your main user, we need to fix that:

sudo mkdir /home/dummy
sudo chown dummy:users /home/dummy
sudo -u dummy mkdir /home/dummy/.config
sudo -u dummy mpg123 /home/path/music.mp3

Offline

#13 2019-01-06 16:49:06

makh
Member
Registered: 2011-10-10
Posts: 299

Re: Cron Job during no login

Hi

The above steps done...

I copied the file to home of dummy, and logged in via root:

mpg123 002.mp3 
High Performance MPEG 1.0/2.0/2.5 Audio Player for Layers 1, 2 and 3
	version 1.25.10; written and copyright by Michael Hipp and others
	free software (LGPL) without any warranty but with best wishes
Segmentation fault (core dumped)

$ pwd
/home/dummy

Via sudo user:

sudo -u dummy mpg123 /home/dummy/002.mp3 
High Performance MPEG 1.0/2.0/2.5 Audio Player for Layers 1, 2 and 3
	version 1.25.10; written and copyright by Michael Hipp and others
	free software (LGPL) without any warranty but with best wishes
Segmentation fault

Thankyou

Last edited by makh (2019-01-06 16:51:14)


OS:  Arch  &/  Debian
System: LENOVO ThinkPad E14
Desktop: Xfce

Offline

#14 2019-01-06 16:50:49

seth
Member
Registered: 2012-09-03
Posts: 49,980

Re: Cron Job during no login

man coredumpctl

Offline

#15 2019-01-10 11:43:10

makh
Member
Registered: 2011-10-10
Posts: 299

Re: Cron Job during no login

Hi

coredumpctl -1
TIME                            PID   UID   GID SIG COREFILE  EXE
Thu 2019-01-10 16:39:29 PKT    7599  1003  1003  11 error     /usr/bin/mpg123

Thankyou


OS:  Arch  &/  Debian
System: LENOVO ThinkPad E14
Desktop: Xfce

Offline

#16 2019-01-10 13:18:06

seth
Member
Registered: 2012-09-03
Posts: 49,980

Re: Cron Job during no login

Well, it would certainly be interesting to look into the coredump, don't you think?

Offline

#17 2019-01-11 13:25:23

makh
Member
Registered: 2011-10-10
Posts: 299

Re: Cron Job during no login

Hi

coredumpctl -1 info
           PID: 21723 (mpg123)
           UID: 1003 (dummy)
           GID: 1003 (dummy)
        Signal: 11 (SEGV)
     Timestamp: Fri 2019-01-11 18:17:26 PKT (5s ago)
  Command Line: mpg123 002.mp3
    Executable: /usr/bin/mpg123
 Control Group: /user.slice/user-1000.slice/session-c1.scope
          Unit: session-c1.scope
         Slice: user-1000.slice
       Session: c1
     Owner UID: 1000 (myuser)
       Boot ID: 4dd64fb9c21d4707a63785db1db3f330
    Machine ID: 5b06db0af3da42818af7b0466f6abc6a
      Hostname: arch1
       Storage: /var/lib/systemd/coredump/core.mpg123.1003.4dd64fb9c21d4707a63785db1db3f330.21723.1>
       Message: Process 21723 (mpg123) of user 1003 dumped core.
                
                Stack trace of thread 21723:
                #0  0x00007f95e115dfd0 n/a (n/a)

Thankyou


OS:  Arch  &/  Debian
System: LENOVO ThinkPad E14
Desktop: Xfce

Offline

#18 2019-01-11 13:48:13

seth
Member
Registered: 2012-09-03
Posts: 49,980

Re: Cron Job during no login

Does the strace seriously end after that call?

Offline

#19 2019-01-13 04:42:09

makh
Member
Registered: 2011-10-10
Posts: 299

Re: Cron Job during no login

Hi

Yes...:
https://imgur.com/a/6DfF33j

Thankyou


OS:  Arch  &/  Debian
System: LENOVO ThinkPad E14
Desktop: Xfce

Offline

#20 2019-01-13 08:58:40

seth
Member
Registered: 2012-09-03
Posts: 49,980

Re: Cron Job during no login

OK, PA isn't supposed to run as system-wide service according to https://www.freedesktop.org/wiki/Softwa … ystemWide/ so no surprise inactive users cannot play anything…
My suggestion for a solution would revolve around PA and lennarts gluteus maximus, but it seems possible to run PA as system-wide service https://unix.stackexchange.com/question … md-service - pay attention to the "auth-anonymous=1" and good luck.

Offline

Board footer

Powered by FluxBB