Steve

You saved me a lot of time.

I also had a case where i wanted to check if the script is accessed via cron or directly to do something different later.

I did id like this (maybe not the most elegant way, but useful for somebody) :

// Check if accesses by cron
$accessPath = getcwd();
$realPath = chdir( __DIR__ );
$realPath = getcwd();
if ($accessPath != $realPath){
$cron = 1;
} else {
$cron = 0;
}

Tue, 24/06/2025 - 00:18 Permalink

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <p> <br> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Web page addresses and email addresses turn into links automatically.
  • Lines and paragraphs break automatically.
CAPTCHA