Closed EOM closed 1 year ago
Hi el problem is for ${VARS} ;( supercronic does not support multiple variables..?
My current Crontab file without variables, worked OK
#TangoAPISync.get_deudas_cheques_de_los_clientes_r_e_s_t
0 */30 0-06 * * * * cd /var/www/html/app/ && ../vendors/bin/cake TangoAPISync.get_deudas_cheques_de_los_clientes_r_e_s_t > /home/nobody/CRON_TangoAPISync.get_deudas_cheques_de_los_clientes_r_e_s_t.txt 2>&1
#PedidosYaApiSync.get_orderns_and_push_all_heart_beat_pedidos_ya_api_sync
0 * 00-05,12-23 * * * * cd /var/www/html/app/ && ../vendors/bin/cake PedidosYaApiSync.get_orderns_and_push_all_heart_beat_pedidos_ya_api_sync > /home/nobody/CRON_PedidosYaApiSync.get_orderns_and_push_all_heart_beat_pedidos_ya_api_sync.txt 2>&1
#MagentoApiSync.get_pedidos_comandas_magento_r_e_s_t
0 * 00-05,12-23 * * * * cd /var/www/html/app/ && ../vendors/bin/cake MagentoApiSync.get_pedidos_comandas_magento_r_e_s_t > /home/nobody/CRON_MagentoApiSync.get_pedidos_comandas_magento_r_e_s_t.txt 2>&1
#RappiApiSync.get_orderns_rappi_api_sync
0 * 00-05,12-23 * * * * cd /var/www/html/app/ && ../vendors/bin/cake RappiApiSync.get_orderns_rappi_api_sync > /home/nobody/CRON_RappiApiSync.get_orderns_rappi_api_sync.txt 2>&1
Hi @EOM supercronic does support variables in the crontab, as documented in the Readme, and demonstrated below:
Your issue is that you're trying to access the variable within an inline shell script, and is an behavior you'll see even outside of supercronic does not work:
# FOO=bar; echo "$FOO"
bar
# FOO=bar; bash -c 'echo "$FOO"'
You verified this in your second post: you removed /bin/bash -c ""
part of your command, which is why it works. You should be able to use the crontab from your first post if you remove /bin/bash -c ""
there, as well.
Hi @UserNotFound, OK, with what you say, but the problem with the first crontab was that only the last task was executed, instead of all three. But if I generated a cron with only && in a line it doesn't fail, everything runs fine. That was the weird thing I noticed.
Example This does not fail either and runs OK and use without problem /bin/bash.
APP='CRON_APPS'
HOME='/home/nobody'
BIN_CAKE='vendors/bin/cake'
PATH_APP='/var/www/html/app'
CAKECMD='RappiApiSync.get_orderns_rappi_api_sync'
0 * 00-05,12-23 * * * * /bin/bash -c 'cd $PATH_APP && ../$BIN_CAKE $CAKECMD && ../$BIN_CAKE MagentoApiSync.get_pedidos_comandas_magento_r_e_s_t && ../$BIN_CAKE PedidosYaApiSync.get_orderns_and_push_all_heart_beat_pedidos_ya_api_sync' > ${HOME}/${APP}_all.txt 2>&1
Thank @UserNotFound for your answer as well
Test file ok crontab in docker :
RUN supercronic in docker online In 3 crons only the last one it is always executed. Why is this happening? Is it a bug or my mistake?
File crontab