FoxJr
Posts: 4
Joined: Wed Apr 12, 2017 7:11 am

crontab/bash issues (Pixel OS)

Wed Apr 12, 2017 7:38 am

Dear all,

I'm an owner of a Raspberry Pi 3 unit which I'm currently testing for digital signage use. The problem i'm having is with bash commands calling chromium-browser.

startup script
Location: /home/pi/Scripts/startup.sh

Cron -l (in sudo mode)
30 9 * * * /home/pi/Scripts/startup.sh

-----------------------------------------------------------
!#/bin/bash

#Reset OS
#/sbin/shutdown -r now

#Launch Chromium
/usr/bin/chromium-browser

#End
-----------------------------------------------------------

File permissions are set all to anyone

If i run this script from terminal it works fine, however if i can this via crontab at the specified time it never executes, therefore chromium never starts. However if i comment the command to launch chromium and instead remove the comment from the restart OS command it works fine. So i believe that i'm doing something wrong when it comes to launching the application.

Can anyone highlight the issue? as i'm really puzzled.

Hope I provided you with all information needed, thanks in advance for your help!

User avatar
Paeryn
Posts: 2966
Joined: Wed Nov 23, 2011 1:10 am
Location: Sheffield, England

Re: crontab/bash issues (Pixel OS)

Wed Apr 12, 2017 9:28 am

Why are you wanting to open a browser owned by root? Wouldn't this be better in the user's (pi's) crontab?

Anyway it probably isn't working as root doesn't have the authority to open a window on another user's desktop.

I assume the mistake in the shebang is a typo when copying it to here (you have !# rather than #!).
She who travels light — forgot something.

User avatar
RaTTuS
Posts: 10559
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK
Contact: Twitter YouTube

Re: crontab/bash issues (Pixel OS)

Wed Apr 12, 2017 11:08 am

you really dont want to use cron to run stuff on a desktop and you really really dont want to run a root browser on a desktop
use the lxde startup stuff for this
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

User avatar
kusti8
Posts: 3439
Joined: Sat Dec 21, 2013 5:29 pm
Location: USA

Re: crontab/bash issues (Pixel OS)

Wed Apr 12, 2017 11:59 am

Chromium will refuse to run as root. You could make a script and add it to the lxde startup script to wait until the right time comes and then start Chromium
There are 10 types of people: those who understand binary and those who don't.

FoxJr
Posts: 4
Joined: Wed Apr 12, 2017 7:11 am

Re: crontab/bash issues (Pixel OS)

Wed Apr 12, 2017 12:52 pm

Thanks for your prompt reply guys, will check this lxde startup procedure and revert back.

User avatar
RaTTuS
Posts: 10559
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK
Contact: Twitter YouTube

Re: crontab/bash issues (Pixel OS)

Wed Apr 12, 2017 12:54 pm

FoxJr wrote:Thanks for your prompt reply guys, will check this lxde startup procedure and revert back.
[pedant] you don't revert back, you revert[/pedant]
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

Martin Frezman
Posts: 1009
Joined: Mon Oct 31, 2016 10:05 am

Re: crontab/bash issues (Pixel OS)

Wed Apr 12, 2017 1:10 pm

RaTTuS wrote:
FoxJr wrote:Thanks for your prompt reply guys, will check this lxde startup procedure and revert back.
[pedant] you don't revert back, you revert[/pedant]
Actually, you don't revert at all. You "report back".
If this post appears in the wrong forums category, my apologies.

FoxJr
Posts: 4
Joined: Wed Apr 12, 2017 7:11 am

Re: crontab/bash issues (Pixel OS)

Wed Apr 12, 2017 2:55 pm

Tried with lxde startup, no success.

Here is what i did:
sudo nano /etc/xdg/lxsession/LXDE-pi/autostart

added the following at the end of the file;
@chromium-browser (1st attempt)
@/usr/bin/chromium-browser (2nd attempt)

Any ideas?

FoxJr
Posts: 4
Joined: Wed Apr 12, 2017 7:11 am

Re: crontab/bash issues (Pixel OS)

Wed Apr 12, 2017 3:13 pm

Guys just a few lines to inform you that issue has been fixed.

Here is how:

sudo nano ~/.config/lxsession/LXDE-pi/autostart
@chromium-broswer (or any other application you want to run)

Reference (method 2)
http://www.raspberrypi-spy.co.uk/2014/0 ... e-desktop/

Thanks for all your help

Martin Frezman
Posts: 1009
Joined: Mon Oct 31, 2016 10:05 am

Re: crontab/bash issues (Pixel OS)

Wed Apr 12, 2017 3:15 pm

sudo???
If this post appears in the wrong forums category, my apologies.

User avatar
DougieLawson
Posts: 39121
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: crontab/bash issues (Pixel OS)

Thu Apr 13, 2017 7:35 am

FoxJr wrote: sudo nano ~/.config/lxsession/LXDE-pi/autostart
Stop prefixing every command with sudo, you'll break your system or compromise security if you persist in that pernicious practice.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

Return to “Other programming languages”