I start an sh script with crontab to create an xml file ("MyXML") with "MyApp.exe" using config files from "SpecificDirectory":
#!/bin/bash
cd ~/MyDirectory
mono MyApp.exe ./SpecificDirectory
And then there is another cron tab processing the MyXML file into the database.
1 7 * * * php /var/www/html/artisan xml:process MyXML >> /var/log/xml-process.log 2>&1
Can I add that artisan xml process to the shell script, so it is not executed by the crontab, but immediately after the exe finished creating MyXML?
If yes, how would that look like?
Sometimes the creating takes longer and the xml:process starts even if the xml is not yet fully created.
I use Ubuntu 16.04 if it's relevant.
As I understand it, you are currently running two separately scheduled tasks from cron
.
A shell script contains a series of commands, which are executed one by one in the order in which they appear, unless specified otherwise.
If your php
command should always be executed after the mono
command completes, then just add it to the bottom of that script and remove the separate cron
entry:
#!/bin/bash
cd ~/MyDirectory
mono MyApp.exe ./SpecificDirectory
# it may be necessary to change directory here
# (but it doesn't look like it, since you're using absolute paths)
php /var/www/html/artisan xml:process MyXML >> /var/log/xml-process.log 2>&1