• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

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