Score:0

Trying to setup cronjob auto-browser or run scripts in Python or PHP

in flag

The situation was I wanted to set up cronjob for webserver on Ubuntu,

the php / python script file would be several sql function, then run automatically update multiple tables.

but after few research, I found:

First I try running scripts.php on Ubuntu terminal such as

$ crontab -e
$ * * * * */usr/bin/php8.0 /var/www/myproject/scripts.php

but Ubuntu terminal return could not find driver, tried re-install pdo-mysql in above PHP just still there;

Currently running directly open the URL with browser.

$crontab -e
$* * * * * export DISPLAY=:0 && firefox https://localhost/project/cron/scripts.php

the .sh scripts using;

#!/bin/bash

# Set maximum amount of remaining firefox processes here
MAX_PROC=2

let COUNT=$(pgrep firefox | wc -l)
for (( i=1; i<=COUNT-MAX_PROC; i++ ))
do
  PID=$(pgrep -o firefox)
  kill $PID
# sleep 3
done

terminal pkill work like charm

30 0 * * * pkill -f firefox.sh

Another option python selenium since the browser needs be gone;

but there's new problem that says: Browser is under remote (reason: Marionette) and opening a blank page;

after few test even the blank page the scripts still work but blank;

After some work still need some help:

  • How to upgrade pdo_mysql in cli-php without modified apache-php;
  • What would be the proper way to disable Browser is under remote;

Welcome any suggestion, Thanks for any help. both Python / PHP acceptable!

WinEunuuchs2Unix avatar
in flag
Usually you ask one question. When you ask multiple questions you get exponential answers.
ReturnError552 avatar
in flag
Really good suggestion. Thank you for point out.
Score:0
in flag

Why would there be a browser opened when you're using wget in cron?

For the scheduled task with a local PHP file, this is generally the easier option:

* * * * * /usr/bin/wget --no-check-certificate -q "https://localhost/project/cron/scripts.php" -O /root/output.txt

No browser will open for this, and the SSL certificate will not be checked for validation (as it's a local site, so it's probably trusted).

ReturnError552 avatar
in flag
Sorry used wrong code, I just using `wget` on the other cron, thank you!
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.