3

I've tried to pass the following command line to Symfony Process component according to Symfony documentation:

use Symfony\Component\Process\Exception\ProcessFailedException;
use Symfony\Component\Process\Process;

$process = new Process(['cat crons/* | crontab -']);
$process->run();

and also the following:

$process = new Process(['cat crons/*', '|', 'crontab -']);

and:

['cat crons/*', '|', 'crontab', '-']

but it doesn't work, it rises an exception:

 The command "'cat /var/www/config/crontab/* | crontab -'" failed.       
                                                                          
  Exit Code: 127(Command not found)                                       
                                                                          
  Working directory: /var/www                                             
                                                                          
  Output:                                                                 
  ================                                                        
                                                                          
                                                                          
  Error Output:                                                           
  ================                                                        
  sh: exec: line 1: cat /var/www/config/crontab/* | crontab -: not found

Have anyone a solution please ?

Stephan Vierkant
  • 9,674
  • 8
  • 61
  • 97
Abdel_91
  • 59
  • 5
  • You want to pipe the output of `cat /var/www/config/crontab/*` to `crontab -`, right? – yivi Oct 14 '21 at 13:01
  • You can pipe input/output with the Process component. But before that, have you tried `['cat crons/*', '|', 'crontab', '-']`? – yivi Oct 14 '21 at 13:03
  • Yes that's right :-) I've tried too : ```['cat crons/*', '|', 'crontab', '-']``` – Abdel_91 Oct 15 '21 at 09:23

0 Answers0