A
A
Alexander2015-10-02 19:06:33
linux
Alexander, 2015-10-02 19:06:33

The command is executed in the terminal, but is not executed in the crontab. (Supload for backups in Selectel), solution?

Hello. Noob in system administration. It is necessary to set up daily backups of a certain folder /var/www/sites to a remote server (Selectel), using one of the tools offered by the company https://blog.selectel.ru/rezervnoe-kopirovanie-vo... .
Edit crontab via SSH as root:
crontab -e
* 7 * * * mysqldump --all-databases -uroot -pPASSWORD > /var/www/sites/dbd/alldb.sql && nowdate=`date +"\%d_\% m_\%y"` && tar -czvf backups/bckp-$nowdate.tar.gz /var/www/sites && supload -u 12345 -k PASSWORD -d 14d -r projectbackups/ddos-guard-projects/ backups && rm backups/*.tar.gz -f
(names and passwords, of course,
Every 7 am, a dump of all server databases is created, the folder with server sites is archived and the finished archive is thrown into the backups folder (in the root directory), and then all the contents from this folder (only this archive is there), is sent to the remote directory (supload) and then removed.
Consistently entered all these commands, everything worked like clockwork.
But when the cron itself starts doing all this, everything is done right up to the creation of the archive. But the last 2 commands (supload - send to a remote server, and then rm - remove) are not executed.
I looked at root's mail, /var/log/cron - I did not find any errors (on a CentOS 6 server).
In the logs /var/log/cron only:
mince6564 CROND[26133]: (root) CMD (mysqldump --all-databases -uroot -pPASSWORD > /var/www/sites/dbd/alldb.sql && nowdate=`date +"\%d_\%m_\%y "` && tar -czvf backups/bckp-$nowdate.tar.gz /var/www/sites && supload -u 12345 -k PASSWORD -d 14d -r projectbackups/ddos-guard-projects/ backups && rm backups/*. tar.gz -f)
i.e. in brackets CMD () the contents correspond to the set of commands that I wrote. As if everything was completed window.
Thank you in advance for your help!!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander, 2015-10-02
@donkarabon

I redirected the error output to /var/log/cron (IT TURNS OUT IT SHOULD BE DONE :D), in the end everything is executed (archived) as before, the process is written in detail to the log, and then everything ends with this: /bin/sh: supload: command not found , that is, really something with the environment. The command does not understand... (accordingly, it does not execute the last rm command, because the previous command was not executed).
The problem turned out to be, of course, in ignorance of the basics of working with the server (I just know the whole thing, because I used to work with ISP Manager at most and there weren’t any problems with the same backup).
In general, the problem turned out to be in the environment. Thanks to Sergey. supload didn't work because was in /usr/local/bin , and all the main commands are in /usr/bin . Moved supload to /usr/bin and it worked. The archive is sent to a remote server, then deleted from the local one.
I will learn how to work with linux, read books and manuals, thanks: 3

V
Vladimir, 2015-10-02
@rostel

write full paths to all directories
or cd (add to command) to the target directory, from where relative paths work

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question