All welcome, thank you for visiting

There is a hosting that has the functionality to run tasks with their cron (task planning). Tasks are performed after a certain period of time. Tell me with the teams. I want to import data from a table file (on hosting) into the site database, in 3 stages, so to speak.

  1. How to make check a specific directory on the hosting for the presence of a file? those. if there is a file - then, if not, then no (ordinary * .sql file for the mysql table)

  2. Import the * .sql file into a specific mysql table (just rewrite the entries in it, the table is initially empty)

  3. After the import is complete - run a specific php page.

  • Gentlemen, I found some separate commands for cron, and unfortunately I am horrified. it seems, on the one hand, he is able to do everything, what he has found about, and how you start to “dig” - that’s even a simple import, which is possible by a locally installed program, is already a problem - frank

1 answer 1

Here is a script to save in the file script.sh, give it the right to run and add to cron

# 1.if [ -f /path/to/file.sql ] then # 2. mysql < /path/to/file.sql # если в mysql используется пароль, то # mysql -p<пароль> < /path/to/file.sql # 3. php /path/to/page.phpfi 
  • thank. I'm going to test - frank
  • 2
    Almost well done, the current normals still write the name of the database when restore is done. Ie mysql dbname </path/to/file.sql. - pyatak
  • of course) it seemed that I forgot something .. again you help me out, nickle)) - ArcherGodson