mirror of
https://github.com/vitodeploy/vito.git
synced 2025-04-17 17:01:37 +00:00
26 lines
529 B
PHP
26 lines
529 B
PHP
<?php
|
|
|
|
namespace App\SSH\Cron;
|
|
|
|
use App\Models\Server;
|
|
|
|
class Cron
|
|
{
|
|
public function __construct(protected Server $server) {}
|
|
|
|
public function update(string $user, string $cron): void
|
|
{
|
|
$command = <<<EOD
|
|
if ! echo '$cron' | sudo -u $user crontab -; then
|
|
echo 'VITO_SSH_ERROR' && exit 1
|
|
fi
|
|
|
|
if ! sudo -u $user crontab -l; then
|
|
echo 'VITO_SSH_ERROR' && exit 1
|
|
fi
|
|
EOD;
|
|
|
|
$this->server->ssh()->exec($command);
|
|
}
|
|
}
|