Hello everyone!
Hope we all had a great week.
Today we will be looking at how to automate our backend.
Most professional developers at a certain point, encounter the need to automate certain processes at the backend such as:
–
- Deleting all obsolete records older than certain dates.
- Sending a unique offer email to new users after some hours of registration.
- Deleting expired URLs from a database
- Promoting students at an exact date.
- Updating or automatically resetting your admin password every 1hour and reporting the new password to your email.
e.t.c
You can do all these by simply writing your PHP script and creating a
cron job to automatically keep running that PHP script at regular interval.
To do that, follow these simple steps below:-
Step 1:
simply login to your online Cpanel and
Scroll to Advanced Tools tab or simply look for and Click on the Cron Jobs icon.
Step 2:
Now you need to provide an email address where reports will be sent to.
Provide your email and click on update mail
Step 3:
Now you will have to provide the common settings from the drop-down which is as simple as just selecting the interval you want your code to run or alternatively, you can specify the minute, hour, day, month or Weekday on which you require your PHP code to run automatically.
Step 4:
Finally, you need to provide the
command line (which is the file path to the PHP file) e.g
/usr/local/bin/php /home/cpanelusername/public_html/nameofphpfile.php
NB: Simply replace cpanelusername with your correct Cpanel username and nameofphpfile with the name of your PHP file.
Then click Add New Cron Job
And just like that your PHP script will automatically run itself at the specified interval. Instantly, you just got automated!
Don’t forget to share this tip with your friends using the share buttons below. Feel free to drop your comments and share your views with us.
Enjoy your day!!
2 Comments