• Please be aware: Kaspersky Anti-Virus has been deprecated
    With the upgrade to Plesk Obsidian 18.0.64, "Kaspersky Anti-Virus for Servers" will be automatically removed from the servers it is installed on. We recommend that you migrate to Sophos Anti-Virus for Servers.
  • 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.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

Question Run Scheduled Tasks With Sql Command In Plesk

Mahdi Elahi

New Pleskian
Hi,
I want Insert a record every minute in specified Table, but
how to set sql command for scheduled tasks in plesk ?
i upload a comman.sql in httpsdocs how to use it in scheduled tasks

q88u_11.png
 
You can create simple bash script with command for sql insert inside and use this script in Command * field with full path.
 
To do what?

Create script databaseupdate.sh with content like:

#!/bin/bash
plesk db "INSERT INTO databasename.tablename ....."


make your script executable with

# chmod +x /path/to/databaseupdate.sh

then specify this script with full path (like /path/to/databaseupdate.sh) in Command* filed of screen above.
 
Thanks , i create bash script and upload it on httpdocs , but in what write in Command scheduled task to execute the script file?
how to use it in scheduled task ?

i write in command filed
/zarbafco/bash.sh

but its not run and show this error
'/zarbafco/bash.sh' is not recognized as an internal or external command, operable program or batch file.
at Plesk impersonation(PipeServer::ServerThread::impersonateRunAs line 726)
at Task execution error(runtask::start line 182)
 
Is it really full path to your script - /zarbafco/bash.sh ?
Did you this script executable as I wrote above?
 
/root/bash/bash.sh is correct.
I hope that content of this script is correct too.
You can just run this script in CLI and check that it works as expected and record is added to database correctly.
After that you can run it as Scheduled task.
 
how to use windows cli or plesk cli ?

in windows i use sql server , is different between my sql or sql serve in bash.script

content of script
mysql --user=[zarbafco] --password=[*********] --database=[zarbafco_itisa] --execute="Insert into zarbafco_itisa.dbo.TSync1 (Id,Name,Age) Values (6,'Sara',25)"
 
Last edited:
For Windows case it's better to use direct mysql command with insert for Command * field.
Maybe Windows experts will provide more relevant suggestions.
 
Back
Top