• 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

Cronjobs not working

EdwardVer

New Pleskian
I was trying to do a cronjob on my server to automate website restore of a demo website.

This is the cronjob task i added with SSH command:
---------------------------------------------------------

sh /var/www/vhosts/mydomain.com/subdomains/restorexx.sh

---------------------------------------------------------

This is the actual file being called:

---------------------------------------------------------

mysql -u root –password=pa$$word < /var/www/vhosts/mydomain.com/subdomains/study.restore/study_.sql
rm -Rf /var/www/vhosts/mydomain.com/subdomains/study/*
cp -Rf /var/www/vhosts/mydomain.com/subdomains/study.restore/* /var/www/vhosts/mydomain.com/subdomains/study/
find /var/www/vhosts/mydomain.com/subdomains/study -type f -print | xargs chmod 644
find /var/www/vhosts/mydomain.com/subdomains/study -type d -print | xargs chmod 755

--------------------------------------------------------

I have never done this before so any advice on how to make it to work would be appreciated.

Thanks in advance!
 
Hi,
Thanks for the reply. I was using via shell (crontab -e) and also tried the task manager in parallels.

I tried to run each line via shell and it execute each line without a problem. This should work in cronjob.

mysql -uuser -ppassword databasename </var/www/vhosts/mydomain.com/subdomains/study.restore/study_.sql
rm -Rf /var/www/vhosts/mydomain.com/subdomains/study/*
cp -Rf /var/www/vhosts/mydomain.com/subdomains/study.restore/* /var/www/vhosts/mydomain.com/subdomains/study/
find /var/www/vhosts/mydomain.com/subdomains/study -type f -print | xargs chmod 644
find /var/www/vhosts/mydomain.com/subdomains/study -type d -print | xargs chmod 755

But the owner group is not correct
 
CHMOD command

BTW, Is this the right CHMOD command? It doesn't seem to work

find /var/www/vhosts/mydomain.com/subdomains/study -type f -print | xargs chmod 644
find /var/www/vhosts/mydomain.com/subdomains/study -type d -print | xargs chmod 755
 
Each line works, ok, but does the shell script work?
If not: chmod u+x -> makes it executable

After creating the cronjob, did you get a message like:
"New conjob installed"?

If not, check crontab:
________________________________________________________________
# crontab -e

sh /var/www/vhosts/mydomain.com/subdomains/restorexx.sh

________________________________________________________________

is not enough, you need to set a time, the job's supposed to start,
something like:
________________________________________________________________
# crontab -e

4 * * * * sh /var/www/vhosts/mydomain.com/subdomains/restorexx.sh

________________________________________________________________

have a look at:
[german]
http://troubadix.dn.fh-koeln.de/unix/cronjobs_syntax.html
[english]
http://www.thegeekstuff.com/2009/06/15-practical-crontab-examples/


But the owner group is not correct
Don't know what you mean, sry.


I'm not sure if find works that way, ask google ;)
 
I already have this :

32 * * * * sh /var/www/vhosts/mydomain.com/subdomains/restorexx.sh on

But the owner group is not correct
What i meant by that is when i manually try each command in shell, the owner/group is set to none. If there is no owner group i cannot access the admi area of the website.

...and i am googling now for 2 hours :p
 
The cron job is save and installed. I can see it with crontab -e

49 * * * * /var/www/vhosts/mydomain.com/subdomains/test.sh

The problem is, it does not execute.
 
Last edited:
Solved

I solved my issue with countless hours of trying.

In Plesk Control Panel, I have choosen "Access to the server over SSH : /bin/bash" and used the the "Scheduled Task Manager" to execute the cron job.

30 * * * * /bin/sh /var/www/vhosts/mydomain.com/subdomains/restore.sh

Not it works!
 
Back
Top