vito/app/SSH/Cron/Cron.php
Saeed Vaziry 428140b931
refactoring (#116)
- refactoring architecture
- fix incomplete ssh logs
- code editor for scripts in the app
- remove Jobs and SSHCommands
2024-03-14 20:03:43 +01:00

28 lines
538 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);
}
}