Raspberry Pi program launcher

For general Flowcode discussion that does not belong in the other sections.
Post Reply
RGV250
Posts: 362
http://meble-kuchenne.info.pl
Joined: Sat Mar 19, 2022 4:53 pm
Has thanked: 36 times
Been thanked: 40 times

Raspberry Pi program launcher

Post by RGV250 »

Hi,
I thought about putting it under feature request but I am a long way off needing it.

I have several rather small Raspberry Pi programs that I would like to run from a single Pi.
I think it is only possible to run one program from editing the rc.local or bashrc file.
I could probably put all the code in on program but that would get messy.
I then wondered if it is possible to have a FC chart that calls other programs so the one program is started as normal but that one runs the others.
It would probably only need to run once on boot and then close as the other programs should be running then.

Regards,
Bob

mnfisher
Valued Contributor
Posts: 1763
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 148 times
Been thanked: 831 times

Re: Raspberry Pi program launcher

Post by mnfisher »

Hi Bob,

You can run multiple programs by ending the line with '&'

For example

Prog1&
Prog2&
Prog 3&

Would run all three programs...

Martin

RGV250
Posts: 362
Joined: Sat Mar 19, 2022 4:53 pm
Has thanked: 36 times
Been thanked: 40 times

Re: Raspberry Pi program launcher

Post by RGV250 »

Thanks Martin,
I assume that is a Linux thing.
And the last program ends with & exit 0 as normal.

Regards,
Bob

mnfisher
Valued Contributor
Posts: 1763
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 148 times
Been thanked: 831 times

Re: Raspberry Pi program launcher

Post by mnfisher »

Yes - a Linux (or origianally Unix) thing.

Normally - prog1 (for example) would run prog1 and wait for it to finish. The & runs it and returns immediately (so the program runs as a background task) - I think ps -al shows you all the tasks running ( or you can use top)

If you get the task id (using ps) - then you can kill background tasks using kill -9 task_id)

Martin

RGV250
Posts: 362
Joined: Sat Mar 19, 2022 4:53 pm
Has thanked: 36 times
Been thanked: 40 times

Re: Raspberry Pi program launcher

Post by RGV250 »

Hi,
I think I will need to do a bit of reading in the pub sometime. Years ago (before windows) I knew a lot of the DOS commands but Windows has made us lazy. It wouldn't be so bad if it worked all the time.

Bob

chipfryer27
Valued Contributor
Posts: 1788
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 402 times
Been thanked: 618 times

Re: Raspberry Pi program launcher

Post by chipfryer27 »

Hi

Far from a "guru" but wouldn't adding to .bashrc not cause them to run every time you logged in meaning the potential for multiple instances? I think I remember something about this on the RPi forum.

I'm assuming you are "headless", referring to FC code rather than "downloaded apps" so to speak, and want them all to automatically run at boot?

With the intro of "systemd" it makes things a bit more stable as it allows the OS to be fully operational before running your codes which may be better than editing rc.local

If you do a search along the lines of "running multiple programs at boot on RPi using systemd" you should get some ideas. Remember permissions too, they catch me out more times than I'll admit to....

Regards

LeighM
Valued Contributor
Posts: 524
Joined: Mon Dec 07, 2020 1:00 pm
Has thanked: 91 times
Been thanked: 280 times

Re: Raspberry Pi program launcher

Post by LeighM »

Another possibility is using crontab @reboot (with a sleep)

Post Reply