SSH into the container and copy the current startup script by typing the following:
$ cp /opt/startup/startup.sh /home
Edit the startup.sh
under /home/startup.sh
and add your changes to the top of the file after #!/bin/sh
. In the sample below, I'll be installing cron to run a cronjob.
# 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
Save the file.
In the Azure Portal configurations, add /home/startup.sh
as the Startup Command and restart the site.
Note, there are two pitfalls to this approach:
- The script must be executable, so either install w/ unix and chmod 755 start.sh or use a git command (see SO).
- The 3pp (here crontab) is installed on every startup, thus you depend on external servers/repositories when starting the webapp.
References for this section: