Jump to content

Recommended Posts

Guest karthi
Posted

To schedule a cronjob on azure app service Linux web application you can follow the steps outlined below,

 

 

mediumvv2px400.png.7430f73b0987a8a0a0c9d5d9e34bd405.png

 

Navigate to “SSH” from azure app services portal and click on Go ->

 

 

mediumvv2px400.png.78e3f2486a148818cfa25d31d57e746f.png

 

mediumvv2px400.png.9124e208fc283e8f6c14956f5a002c80.png

 

Create a script file in /home with name as start.sh and add the below lines to the script file and save the file.

 

Command to create a script file - touch /home/start.sh

 

Open the file using vim editor: vi /home/start.sh and copy the below code

 

 

# Installing cron

apt-get update -qq && apt-get install cron -yqq

# Starting cron

service cron start

#cron scheduler

(crontab -l 2>/dev/null; echo "* * * * * find /home/BackupLogs -type f -size 1k -delete ")|crontab

 

 

Post that, you can add the created script as a startup command which would install the cron, start the cron and schedule the cron during startup. To add as a startup command, navigate to Azure portal -> Configuration blade -> General settings tab and provide as below,

 

 

 

 

mediumvv2px400.png.2c7ba8aa38990bdbf9edb93ae331befb.png

 

 

 

In the above sample code, it checks for all the files with size 1KB in /home/BackupLogs and delete them for every minute.

 

 

 

Based on your convenience you can adjust the CRON scheduler time and command

 

Continue reading...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...