• We value your experience with Plesk during 2024
    Plesk strives to perform even better in 2025. To help us improve further, please answer a few questions about your experience with Plesk Obsidian 2024.
    Please take this short survey:

    https://pt-research.typeform.com/to/AmZvSXkx

  • We are developing a new feature in Plesk that will help you promote your websites or business on social media. We want to conduct a one-hour online UX test to present the prototype and collect feedback. If you are interested in the feature, please book a meeting via this link.
    Thank you in advance!
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.

Resolved Facing Problem run cron job

psclip

New Pleskian
Hi,
How can I run cron job every min, 2 min, 3min, 10min, 2 min, every hour, and once a day? I'm facing an error when I run the command. I attached a screenshot. I would love to hear from you soon.
picturemessage_y1umkn14.gcx.png
Best
Joynul
 
Select "Cron Syntax" instead of "Hourly", then you are free to configure the job as you are used to, e.g.
*/3 * * * * (every three minutes)
15 * * * * (every hour at minute 15)
etc.

When you run a PHP script it might be better to select "PHP script" from the radio buttons and omit the /usr/bin/php part of the command. "Only a simple command is a good command."
 
Dear Peter,
I tried with Cron Syntax, Still, I'm facing the same issue. Please have a look at my screenshot. Any solutions? I would love to hear from you soon.
Thanks!!
 

Attachments

  • syn cron.png
    syn cron.png
    76.8 KB · Views: 57
Try to run it with "PHP", omit the /usr/bin/php, because in a subscription you cannot access the /usr/bin/php that is located outside.

Also, your error could simply mean that the script execution itself fails, e.g. syntax error etc. Check the script on the console.
 
Hi Peter,
Again really sorry to bother you. The script is correct, I set up MailWizz in a subdomain. Let me know please how do I solve the issues, I will be grateful to you,
Thanks!!
 
Did you check the cron log? What kind of error is being displayed?

Try 'Run a PHP script', path to the script ... and try to remove '> / dev / null 2> & 1'.

I had a similar bug with a cron job on a subdomain and this solution worked for me.
 
Select "Cron Syntax" instead of "Hourly", then you are free to configure the job as you are used to, e.g.
*/3 * * * * (every three minutes)
15 * * * * (every hour at minute 15)
etc.

When you run a PHP script it might be better to select "PHP script" from the radio buttons and omit the /usr/bin/php part of the command. "Only a simple command is a good command."
Which one Runs Once a day! Please help me thanks!!
 
When you enter hour and minute, the job is executed at the given time once a day, for example
17 5 * * * *
will be executed at 5:17 a.m.
 
When you enter hour and minute, the job is executed at the given time once a day, for example
17 5 * * * *
will be executed at 5:17 a.m.
Thank you so much I was able to run by adding this code
/opt/plesk/php/7.4/bin/php
/opt/plesk/php/7.3/bin/php
/opt/plesk/php/7.2/bin/php
/opt/plesk/php/7.1/bin/php
 
Hello Peter & psclip,


I am facing a similar issue I can't seem to find a fix, please help!

My server is Ubuntu 20.04.2 + Plesk Obsidian (latest version) and I am attempting to get Mailwizz running on a subdomain using PHP 7.4.22.


The cron tasks I wish to run are:

# Campaigns sender, runs each minute.
* * * * * /usr/bin/php -q /var/www/vhosts/mydomain.com/mm.mydomain.com/apps/console/console.php send-campaigns >/dev/null 2>&1

# Queue handler, runs each minute.
* * * * * /usr/bin/php -q /var/www/vhosts/mydomain.com/mm.mydomain.com/apps/console/console.php queue >/dev/null 2>&1

# Transactional email sender, runs once at 2 minutes.
*/2 * * * * /usr/bin/php -q /var/www/vhosts/mydomain.com/mm.mydomain.com/apps/console/console.php send-transactional-emails >/dev/null 2>&1

# Bounce handler, runs once at 10 minutes.
*/10 * * * * /usr/bin/php -q /var/www/vhosts/mydomain.com/mm.mydomain.com/apps/console/console.php bounce-handler >/dev/null 2>&1

# Feedback loop handler, runs once at 20 minutes.
*/20 * * * * /usr/bin/php -q /var/www/vhosts/mydomain.com/mm.mydomain.com/apps/console/console.php feedback-loop-handler >/dev/null 2>&1

# Delivery/Bounce processor, runs once at 3 minutes.
*/3 * * * * /usr/bin/php -q /var/www/vhosts/mydomain.com/mm.mydomain.com/apps/console/console.php process-delivery-and-bounce-log >/dev/null 2>&1

# Various tasks, runs each hour.
0 * * * * /usr/bin/php -q /var/www/vhosts/mydomain.com/mm.mydomain.com/apps/console/console.php hourly >/dev/null 2>&1

# Daily cleaner, runs once a day.
0 0 * * * /usr/bin/php -q /var/www/vhosts/mydomain.com/mm.mydomain.com/apps/console/console.php daily >/dev/null 2>&1


I have followed your instructions:
  • See screenshot
  • Checked the "Active" box
  • Selected the Task type, radio button "Run a PHP script"
  • For Script path, I removed the /usr/bin/php -q and used the remainder of the syntax and removed the ">/dev/null 2>&1"
  • For with arguments, I left this blank
  • For Run, I changed the option to "Cron style" and input manual syntax, " ***** " (I understand how to set up the cron syntax, no problem and here is a great resource Crontab.guru - The cron schedule expression editor)
  • System user is "root"
  • Description is left blank
  • Notify is "Do not notify"
  • Then I hit the "Run Now" button and I receive the error in the screenshot

@psclip - did you do anything to alter the syntax for the subdomain? I do not understand what you meant by adding the code, "/opt/plesk/php/7.1/bin/php"...

I also tried user: psaadm as some of the system generated cron jobs for this domain have that as the user.
 

Attachments

  • Plesk-Obsidian-Schedule-a-Task.jpg
    Plesk-Obsidian-Schedule-a-Task.jpg
    203.6 KB · Views: 57
Also last piece of information:

Under Tools & Settings > Scheduled Tasks > Crontab shell is "/bin/bash (chrooted)"
 
@hello, Mow, thanks for your reply!

I was able to solve this recently and didn't get a chance to post a reply until now.

Example cron job:
# Queue handler, runs each minute.
* * * * * /usr/bin/php -q /var/www/vhosts/mydomain.com/mm.mydomain.com/apps/console/console.php queue >/dev/null 2>&1

In Plesk Obsidian;
Script path: /var/www/vhosts/mydomain.com/mm.mydomain.com/apps/console/console.php
with arguments: queue

Removed syntax are: /usr/bin/php -q and >/dev/null 2>&1

Run, select option "Cron style" from the drop-down menu and input your cron syntax, " * * * * * " .

As suggested, under notify, I did select, "Errors only" and allowed send notifications to an email address for future errors.

Hit the "Run Now" (for a new cron) or "Apply" button (if updating an existing cron) and then "OK"... works like a charm!

I didn't have to change the system user or the script path locations for my domain/sub-domian.

@Peter & psclip, thanks for your previous posts!
 
Back
Top