Vesta Control Panel - Forum

Community Forum

Skip to content

Advanced search
  • Quick links
    • Main site
    • Github repo
    • Google Search
  • FAQ
  • Login
  • Register
  • Board index Main Section General Discussion
  • Search

Help to setup cronjob with enviroment variables

General questions about VestaCP
Post Reply
  • Print view
Advanced search
4 posts • Page 1 of 1
augustocarmo
Posts: 10
Joined: Thu Aug 23, 2018 8:58 pm

Os: CentOS 6x
Web: nginx + php-fpm
Help to setup cronjob with enviroment variables
  • Quote

Post by augustocarmo » Thu Aug 23, 2018 9:30 pm

Hello, I started to use VestaCP a few weeks now, and I'm just testing and making configurations before migrate my websites to a VPS.

Righ now I'm trying to setup an automated backup using restic and cron.
I installed restic and configure it with success in my server, but all the configuration was done using the root user, not the admin user. And I think that's was part of the problem.

When I configured using the root I added the environment variables to this file:

Code: Select all

/root/.bash_profile
and I can run this command:

Code: Select all

restic backup /home --exclude /home/backup
My first attempt was to just add a cron using the VestaCP panel to run this command.

Image

I can see in the log using cat /var/log/cron that the cron ran but when use the restic snapshot to list the history of backups no new snapshot is created.

Than I started to see some topics in the forum and I tried to run the same command using the admin user, and to resume I can run via ssh this command using the admin user with partial success:

Code: Select all

restic backup /home --exclude /home/backup
I get two errors:

Code: Select all

error: Open: open /home/admin/conf/dns: permission denied
error: Open: open /home/admin/conf/web: permission denied
I tried to add a cron with this command but it didn't work.

When I try to run this command:

Code: Select all

sudo restic backup /home --exclude /home/backup
The password is asked.

I really tried to fix that but is beyond my knowledge, and I would appreciate some help.

Thanks
Top

rhyker2u
Posts: 86
Joined: Thu Jan 19, 2017 11:46 am
Contact:
Contact rhyker2u
Website

Os: Ubuntu 17x
Web: nginx + php-fpm
Re: Help to setup cronjob with enviroment variables
  • Quote

Post by rhyker2u » Sat Sep 08, 2018 2:04 pm

Didn't know it was even possible to setup cronjobs from Vesta CP. However have you tried to execute:

Code: Select all

crontab -e
from ssh cli to see if it works then? And if not, to execute them as 'root' cronjobs instead of 'admin' user ?
Top

maman
Posts: 17
Joined: Mon Aug 27, 2018 3:05 pm

Os: CentOS 4x
Web: apache
Re: Help to setup cronjob with enviroment variables
  • Quote

Post by maman » Sun Sep 09, 2018 11:48 am

Try this

echo 'yourpassword' | sudo restic backup /home --exclude /home/backup
Top

augustocarmo
Posts: 10
Joined: Thu Aug 23, 2018 8:58 pm

Os: CentOS 6x
Web: nginx + php-fpm
Re: Help to setup cronjob with enviroment variables
  • Quote

Post by augustocarmo » Mon Sep 10, 2018 3:37 pm

I added the cronjob using ssh and the root user.
I also added the environment variables in my script, that way the variables are always set before run the script.
Top


Post Reply
  • Print view

4 posts • Page 1 of 1

Return to “General Discussion”



  • Board index
  • All times are UTC
  • Delete all board cookies
  • The team
Powered by phpBB® Forum Software © phpBB Limited
*Original Author: Brad Veryard
*Updated to 3.2 by MannixMD
 

 

cron

Login  •  Register

I forgot my password