I am working on a project where i need to setup cron jobs dynamically. for your acknowledge i am using linux e2-user amazon instance. i have added cron job and its running fine if i run from terminal but not works when i run url from web browser or postman.
here is my code for dynamic cron job in demo2.php file.
$output = shell_exec('crontab -l');
file_put_contents('crontab.txt', $output.'20 14 * * * php /var/www/html/jackpot/demo.php'.PHP_EOL);
exec('crontab crontab.txt');
when i run in terminal php demo.php
it works fine and run two cron jobs. If i run same file in browser like this http://ec2-52-23-188-162.compute-1.amazonaws.com/jackpot/demo2.php
and after run this file i go to my terminal and type crontab -l
it shows nothing. i dont know whats going wrong with this.all linux command are also working perfectly.
Please tell me any perfect solution for this.
Thank you