Score:0

Cronjob Set off from Web Portal

cv flag

Ubuntu 20.04 Apache

Is there a way for a cron job to be executed from the web portal?

We have tried to trigger the cron job using different methods.

PHP - Adding Cron Job

    static public function save_cron_jobs($jobs = array()) {
        $save_cron_query = 'echo "'.self::array_to_string($jobs).'" | crontab -u main -';
        $output = shell_exec($save_cron_query);
        echo($save_cron_query . PHP_EOL . PHP_EOL);
        return $output; 
    }

We did find success in this before when running the code on a centos server.

We have also tried adding the web user "www-data" to the cron include list.

raj avatar
cn flag
raj
You are using option `-u main` to crontab. Is your web script running under user `main`? You cannot modify crontab of a different user, unless the code is running as root.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.