Perhaps if I ask for information a different way? Descriptions show what you think is happening, not necessarily what actually is happening.
What do you think we need to see to help you?
Perhaps if I ask for information a different way? Descriptions show what you think is happening, not necessarily what actually is happening.
What do you think we need to see to help you?
I don't know. I will try something else indeed: isolating a minimal script and post it with all command used on bash and cron. My script is probably too complex to explore line by line what could play up.
Here is my crontab:
which works partially. Started this way, only the "cp" command of the following script works, "bin1 test" doesn't start.Code:crontab -l | { cat; echo "*/1 * * * * pgrep -f test6 > /dev/null || ~/Documents/Linux/test6"; } | crontab -
My test script is now this (for test purpose):
Code:#!/bin/bash # to check if script works cp /etc/os-release /home/mohicann/os-release # to start test /home/mohicann/bin1 test >> ~/data.txt
- If "bin1 test" is launched from console alone, it works.
Parent is "bash".
- If my script "test6" is launched from console, everything works.
"test6": parent is "bash".
"bin1 test": parent is "test6".
- If my script "test6" is launched from double-click, everything works as well.
"test6": parent is "dolphin".
"bin1 test": parent is "test6".
If all cases, everything works: os-release is copied and/or "bin1 test" sends its data to data.txt.
When I shut down my script test6, bin1 is still running, but no longer provides data to data.txt. Moreover it's parent becomes systemd.
PS: even with this crontab, it doesn't work:
But if I remove "bin1 test" from my script, even this crontab works (it copies os-release each minute):Code:crontab -l | { cat; echo "*/1 * * * * /home/user/bin1 test >> /home/user/data.txt"; } | crontab -
Code:crontab -l | { cat; echo "*/1 * * * * ~/test6"; } | crontab -
Last edited by mohicann; June 7th, 2018 at 08:21 PM.
Even when correcting my script, it still doesn't work :
Code:#!/bin/bash # to check if script works cp /etc/os-release /home/mohicann/os-release # to start test /home/mohicann/bin1 test >> /home/mohicann/data.txt
Last edited by mohicann; June 7th, 2018 at 08:20 PM.
Maybe bin1 is seg-faulting or something like that. Try:
If it is seg-faulting you should get a core in your home directory, which you can then debug with gdb and get a backtrace.Code:#!/bin/bash # to check if script works cp /etc/os-release /home/mohicann/os-release # to start test ulimit -c unlimited /home/mohicann/bin1 test >> /home/mohicann/data.txt
It looks like 'bin1' might need environment vars to run. These are usually given by an interactive shell, or the desktop.
Try this:
This would force the execution of ~/.bashrc too.Code:#!/bin/bash source ~/.profile # to check if script works cp /etc/os-release /home/mohicann/os-release # to start test /home/mohicann/bin1 test >> /home/mohicann/data.txt
If 'bin1' needs a graphical environment, you need an extra variable at the crontab level:
You may want to use DISPLAY=:0.0 if you have a multiple monitor setup.Code:crontab -l | { cat; echo "*/1 * * * * pgrep -f test6 > /dev/null || env DISPLAY=:0 ~/Documents/Linux/test6"; } | crontab -
Hope it helps. Let us know how it goes.
Regards.
Thank you very much for your replies.
I keep this as I've already had a seg-faulting message on another setup, I may need it to solve that one day or another.
It worked! Well done! I'll check everything to ensure there is nothing left, but at least the stubborn process eventually gave up... Now its starts and provides its data when launched from cron!
Thank you very much all for your help!
Last edited by mohicann; June 7th, 2018 at 11:56 PM.
Bookmarks