×


Add Cron Job in VestaCP - How to do it

Are you trying to add Cron Job in VestaCP?

This guide will help you.


Cron is a time-based job scheduler that schedules jobs (such as commands and shell scripts) to run periodically at fixed times, days or intervals.

Adding cron on VestCP can be easily implemented from the admin panel.

Here at Ibmi Media, as part of our Server Management Services, we regularly help our Customers to perform VestaCP related tasks.

In this context, we shall look into how to add Cron Job in VestaCP.


Steps to add cron jobs in VestaCP:

Following are the steps that our Support Experts take to configure cron jobs in VestaCP:

1. Start by connecting to VestaCP account.


2. Then click the CRON tab in VestaCP.


3. From here we can see the list of cron jobs. To create a new one, click the ADD CRON JOB button (green button “+”).


4. After that, we must enter the Command and the interval at which we want the cron job to execute.


Generally, VestaCP has some predefined values.

So, we can choose the value we want and click the Generate button.


Cron Job Tabs available in Vestacp:

a. Minutes Tab: From the Minutes tab, we may select any option from the dropdown menu, then click generate. Every minute represents an asterisk (*) in the “Minutes” field on the left. Every 15 minutes would be reflected as */15, and so on.

b. Hourly Tab: The Hourly tab allows the cron job to be scheduled on the 0th, 15th, 30th or 45th minute of every 1, 2, 6 or 12 hours.

c. Daily Tab: The Daily tab allows the cron job to be scheduled every single, every odd or even or every 3, 5, 10 or 15 days. Beyond this, the cron job can be scheduled down to the hour and minute.

d. Weekly Tab: The Weekly tab allows scheduling for weekdays only, weekends only, every day or specific days of the week. Then the hour and minute can be specified.

e. Monthly Tab: The Monthly tab allows scheduling for every single, every odd or even, every 3 or 6 or a specific month. From there, the date, hour and minute can be selected.


5. We can also EDIT or DELETE cron jobs. Using the buttons available on the right side.


For checking  the cron jobs, we can use the following command:

[root@webcp ~]# crontab -u ibmimedia -l
MAILTO=ibmimedia@ibmimediacares.com
CONTENT_TYPE=”text/plain; charset=utf-8″
* * * * * php /home/ibmimedia/cron.php
[root@webcp ~]#

And to check the cron job log for a specific user, use:

$ cat /var/log/cron | grep ibmimedia
[root@webcp ~]# cat /var/log/cron | grep ibmimedia
Mar 30 08:06:01 webcp crond[188]: (ibmimedia) RELOAD (/var/spool/cron/ibmimedia)
Mar 30 08:06:01 webcp CROND[16439]: (ibmimedia) CMD (/home/ibmimedia/cron.php)
Mar 30 08:07:01 webcp CROND[16475]: (ibmimedia) CMD (/home/ibmimedia/cron.php)
Mar 30 08:07:11 webcp crontab[16484]: (root) LIST (ibmimedia)
Mar 30 08:08:01 webcp CROND[16488]: (ibmimedia) CMD (/home/ibmimedia/cron.php)
Mar 30 08:09:01 webcp CROND[16497]: (ibmimedia) CMD (/home/ibmimedia/cron.php)
Mar 30 08:10:01 webcp CROND[16516]: (ibmimedia) CMD (/home/ibmimedia/cron.php)
Mar 30 08:11:01 webcp CROND[16712]: (ibmimedia) CMD (/home/ibmimedia/cron.php)
Mar 30 08:12:01 webcp CROND[16725]: (ibmimedia) CMD (/home/ibmimedia/cron.php)
Mar 30 08:12:01 webcp crontab[16731]: (root) LIST (ibmimedia)
Mar 30 08:13:01 webcp CROND[16737]: (ibmimedia) CMD (/home/ibmimedia/cron.php)
Mar 30 08:14:01 webcp CROND[16748]: (ibmimedia) CMD (/home/ibmimedia/cron.php)
Mar 30 08:15:01 webcp CROND[16761]: (ibmimedia) CMD (/home/ibmimedia/cron.php)
Mar 30 08:16:01 webcp CROND[17277]: (ibmimedia) CMD (/home/ibmimedia/cron.php)
Mar 30 08:17:01 webcp CROND[17287]: (ibmimedia) CMD (/home/ibmimedia/cron.php)
Mar 30 08:18:01 webcp CROND[17302]: (ibmimedia) CMD (/home/ibmimedia/cron.php)
[root@webcp ~]#


[Need urgent assistance to fix VestaCP issues? We are available 24*7. ]


Conclusion

This article covers steps to add cron jobs in VestaCP. Using VestaCP, you can add mail accounts, databases, Cron jobs, and a whole lot more with just a few clicks. Cron jobs help automize certain commands that need to run regularly, this ensures everything runs smoothly. 


Vesta Control Panel (VestaCP) is an open source hosting control panel that can manage multiple websites, create and manage email accounts, create and manage FTP accounts. Also, manage MySQL database and DNS records.


How to setup a CRON job using VestaCP ?

1. Move to the “CRON” tab then mouse over the plus symbol and click on “Add Cron Job”;

2. Enter the command you would like to execute and make sure to include the necessary privileges such as sudo if your command requires it. Use the frequency generator on the right side of the options to set how often you would like the command to execute.

3. Finally, click Generate to confirm the frequency and then click Add to finish adding the Cron job.

Note: Before adding a cron job be sure to test it out first to ensure it works.