@BheeshamLohana Did you solve the issue, and would you be so kind as to share your cron configuration script, please?
How do I run Cronjobs on Linux App Service
I have configured startup script as well as configured the cron job manually within Linux Container running PHP app. The script is set properly and when running the script manually from within container it is working as expected but the cron schedule do not work.
I am also not able to find the cron job logs to check for any errors.
I installed cron as follows;
Installing cron
apt-get update -qq && apt-get install cron -yqq
service cron start
mkdir /home/BackupLogs
(crontab -l 2>/dev/null; echo "*/5 * * * * cp /home/LogFiles/*.log /home/BackupLogs")|crontab
It would be great if someone can direct me to the right path. What wrong I am doing here?
Where do I find the cron job logs as well. Under /var/log I do not see syslog file or any log file related to cron.
2 answers
Sort by: Most helpful
-
-
brtrach-MSFT 16,686 Reputation points Microsoft Employee
2022-07-19T05:09:27.647+00:00 @BheeshamLohana Thank you for your question regarding cronjobs on Linux App Services.
Since the steps provided for a Linux blessed image app service did not work and you mention using a Linux container, I am going to assume you are using a custom container Linux app service. The steps to use cronjobs are different in this situation.
To Enable cron, add the following line to Dockerfile:
RUN apt-get install -yqq cron
And following line in the container init script (init_container.sh)
(crontab -l && echo "* * * * * echo 'hello from cron' >> /home/site/wwwroot/cron1.txt")|crontab
In this case we will write “hello from cron” to file /home/site/wwwroot/cron1.txt every minute. You can replace this with anything else you wish to run periodically.
echo 'hello from cron' >> /home/site/wwwroot/cron1.txt
Please let us know if this approach helps to resolve your requirement. If not, please let us know so we can assist you further.