I have a linux server for my joomla website. I am importing xml feeds (around 200). The component give a tool which list all the cron job commands to automaticaly make the feeds import.
I don’t want to add one by one each cron job.
So my idea is to make one cron job which will call a shell script command. Inside this script I will put all these commands.
Problem1: I have to make the import one by one. So the shell script should look like
/usr/bin/php /home/website/public_html/superf/cli/com_cmdealaggregator_import_cron.php --id=2
wait... until import is finished...
/usr/bin/php /home/website/public_html/superf/cli/com_cmdealaggregator_import_cron.php --id=3 wait... until import is finished... etc...
But I guess we cannot know when import is finished? In this case we will wait a few minutes?
Problem 2: I have 200 feeds to import. If for example I run the cron job once per week and the cron job from previous week is not finished… Then I’ll have 2 cron jobs running and this could use all the ressource of server… And it will be down. So I had the idea to put a line of code which will write a value in a indicator.txt file.
If inside indicator.txt file, there is line: cronjob_finished = true Then cron job can start
If inside indicator.txt file, there is line: cronjob_finished = false Then cron job cannot start
As a resume, the code should look like this:
#!/bin/sh
# This is some secure program that uses security.
# read indicator.txt
if cronjob_finished = false then
STOP THE SCRIPT
else
let's start the script
/usr/bin/php /home/website/public_html/superf/cli/com_cmdealaggregator_import_cron.php --id=2
wait... until import is finished... OR ... wait a few minutes...
/usr/bin/php /home/website/public_html/superf/cli/com_cmdealaggregator_import_cron.php --id=3
wait... until import is finished... OR ... wait a few minutes...
/usr/bin/php /home/website/public_html/superf/cli/com_cmdealaggregator_import_cron.php --id=4
wait... until import is finished... OR ... wait a few minutes...
etc.......
write in indicator.txt, cronjob_finished = true
fi
Is there any expert who will accept to help me please?