Bobcares

Here’s how we set up Webmin cron

by | May 14, 2019

Cron is one of the most useful utilities in Linux operating systems.

It allows running scheduled tasks like disk space monitoring, system maintenance easy.

In Webmin, there is a feature to set up cron jobs that make users schedule task when they are out of workplace.

At Bobcares, we often get requests from our customers to configure “Webmin cron” as part of our Server Management Services.

Today, we’ll see how our Support Engineers add cron jobs in Webmin and fix the related issues with it.

 

 

How we set up Webmin cron

Setting a cron job is a great way to automate a specific task in Webmin.

Let’s see how we configure cron jobs in Webmin by following the steps below.

1. Initially, we log in to Webmin admin panel.

2. Next, we navigate to Webmin> System> Scheduled Cron Jobs.

3. Then, we click the Create a new scheduled cron job button.

4. In Execute cron job as field we select the user & enter the script in Command field.

5. And under When to execute section we select Times and dates selected below to enter the minutes, hours, days, months, weekdays.

6. Finally, to test the cron job click Save and Run Now.

Now, you can see all the listed scheduled cron jobs like this.

 

Common errors & fixes after setting cron job in Webmin

Even after configuring cron job in Webmin, we often see some common errors.

Let’s take a closer look at each one of them & how our Support Engineers fixed it.

 

1. Wrong command in cron

Recently one of our customers reported us that after setting the command in cron job to automatically make PC sleep & wake every day, it failed to run the task. The command is:

/usr/sbin/rtcwake -m mem -l -t $(date +\%s -d 'tomorrow 07:20')

This happens because the command entered was incorrect and it failed to execute.

So, to solve the problem we took the following steps.

1. First, we checked the cron log file to see the cron jobs.

 grep "CRON" /var/log/syslog

2. We found that the cron command truncates like this:

/usr/sbin/rtcwake -m mem -l -t $(date +\%s -d 'tomorrow 07:20')

3. In Webmin, special character % is masked automatically as \%. So, we corrected the command as:

/usr/sbin/rtcwake -m mem -l -t $(date +%s -d 'tomorrow 07:20')

4. Finally, we restarted the service.

systemctl restart crond.service

That fixed the problem & the user could execute the cron job.

 

2. Incorrect Permission

Similarly, another customer approached us with a problem after executing crontab, it resulted in an error like “/usr/bin/crontab: Permission denied”.

Often this error happens when the corresponding user doesn’t have the permission to execute the cron job.

As a result, it prevents the Webmin cron module to work properly.

So, to solve this error we performed the following steps.

1. First, we checked the list of users.

ls /var/spool/cron/crontabs

2. Next, we checked the user permission by running this command:

ls /usr/bin/crontab

3. By analyzing, we found that the user didn’t have any permission. So, we granted permissions by running this command:

chmod 2755 /usr/bin/crontab

4. Finally, we restarted the services.

That fixed the problem & the user could run the cron job without any failure.

 

3. Broken PHP module

Sometimes crontab does not work if the PHP module is not properly installed. PHP script executed with a cron job requires a specific php.ini file.

To execute cron job correctly we installed PHP on the Webmin server by running the command:

apt-get install php7.0-cli

Once PHP installed, we executed the PHP command & the cron job like this.

php /var/www/example.com/public_html/crons.php

 

[Having trouble after setting cron job in Webmin? We’ll fix it for you.]

 

 

Conclusion

To be more precise, the cron job help users to schedule tasks that make it easier. Today, we saw how our Support Engineers configured Webmin cron & fixed the top 3 common errors related to it.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie
_clck, _clsk, CLID, ANONCHK, MR, MUID, SM

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

_reb2bgeo - The visitor's geographical location

_reb2bloaded - Whether or not the script loaded for the visitor

_reb2bref - The referring URL for the visit

_reb2bsessionID - The visitor's RB2B session ID

_reb2buid - The visitor's RB2B user ID

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid
_reb2bgeo, _reb2bloaded, _reb2bref, _reb2bsessionID, _reb2buid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF