{"id":47359,"date":"2019-12-07T03:01:30","date_gmt":"2019-12-06T17:01:30","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/ITblog\/?p=47359"},"modified":"2020-04-20T08:13:48","modified_gmt":"2020-04-19T22:13:48","slug":"troubleshooting-landing-page-crontab-curl-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/troubleshooting-landing-page-crontab-curl-tutorial\/","title":{"rendered":"Troubleshooting Landing Page Crontab Curl Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/Mac\/tmp_issue.pdf\"><img decoding=\"async\" style=\"border: 15px solid pink;\" alt=\"Troubleshooting Landing Page Crontab Curl Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/Mac\/tmp_issue.gif\" title=\"Troubleshooting Landing Page Crontab Curl Tutorial\"  style=\"float:left;\"   \/><\/a><p class=\"wp-caption-text\">Troubleshooting Landing Page Crontab Curl Tutorial<\/p><\/div>\n<p>Back earlier in December (2019) the crontab\/curl work of <a title='Landing Page Mobile Phone Crontab Curl Tutorial' href='#lpmpcct'>Landing Page Mobile Phone Crontab Curl Tutorial<\/a> must have been disrupted.<\/p>\n<blockquote><p>\nWhy think that?\n<\/p><\/blockquote>\n<p>The RJM Programming <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/\" title=\"RJM Programming Landing Page\">Landing Page<\/a> dropdown of blog tutorial links was missing something &#8230; <a target=_blank title='?' href='https:\/\/www.youtube.com\/watch?v=uhiCFdWeQfA'>anyone, anyone<\/a>? &#8230; yes, <a target=_blank title='?' href='https:\/\/en.wikipedia.org\/wiki\/Sunil_Gavaskar'>Sunil Gavaskar<\/a> &#8230; its blog posting links.  And how are they created each day &#8230; <a target=_blank title='?' href='https:\/\/www.youtube.com\/watch?v=uhiCFdWeQfA'>anyone, anyone<\/a>? &#8230; yes, <a target=_blank title='?' href='https:\/\/en.wikipedia.org\/wiki\/Laika'>Laika<\/a>, look down to <a title='Landing Page Mobile Phone Crontab Curl Tutorial' href='#lpmpcct'>Landing Page Mobile Phone Crontab Curl Tutorial<\/a> to read all about it.<\/p>\n<blockquote><p>\nDo you think it would be good to try, via ssh access what crontab\/curl automates on the RJM Programming web server, but on the command line?\n<\/p><\/blockquote>\n<p>Excellent suggestion!<\/p>\n<p><code><br \/>\n$ curl HTTP:\/\/www.rjmprogramming.com.au\/PHP\/tutorial_options.php<br \/>\n&lt;b&gt;Error 3: Error writing file '\/tmp\/MYpxajPE' (Errcode: 28)&lt;\/b&gt;&lt;option selected='selected' value=' '&gt;Tutorials (show blog, toggle sort order) ...&lt;\/option&gt;<br \/>\n<\/code><\/p>\n<blockquote><p>\nAh!  Do you think a diskspace examination of the \/tmp disk on this Linux web server would reveal anything useful?\n<\/p><\/blockquote>\n<p>You&#8217;re on a roll!<\/p>\n<p><code><br \/>\n$ df -k \/tmp<br \/>\nFilesystem     1K-blocks   Used Available Use% Mounted on<br \/>\n\/usr\/tmpDSK       544256 513316      3292 100% \/tmp<br \/>\n<\/code><\/p>\n<blockquote><p>\nWow, that&#8217;s bad!  Do you think a file listing examination of the \/tmp disk on this Linux web server would reveal anything useful?\n<\/p><\/blockquote>\n<p>Have you been reading the script to all this?<\/p>\n<p><code><br \/>\n$ ls -l \/tmp<br \/>\ntotal 490508<br \/>\ndrwxrwxrwt  114 owner    group      294912 Dec  2 03:54 .\/<br \/>\ndr-xr-xr-x.  25 owner    group        4096 Dec  1 04:49 ..\/<br \/>\n-rw-r--r--    1 owner    group          32 Aug  9  2014 adminer.key<br \/>\n-rw-r--r--    1 owner    group          27 Aug 26  2014 aexception.is<br \/>\ndrwx------    2 owner    group        4096 Jun 16  2018 ansible_Hinjci\/<br \/>\n-rw-r--r--    1 owner    group      225887 Dec  2 02:04 basegetmelist.is<br \/>\n-rw-r--r--    1 owner    group      225887 Dec  2 02:01 basegetmelist.wis<br \/>\n-rw-r--r--    1 owner    group       43615 Jan 18  2015 basegetmelist.wisold<br \/>\n-rw-r--r--    1 owner    group       17099 Apr  8  2014 BatsAndBall.tcl<br \/>\n-rw-r--r--    1 owner    group      130989 Apr 23  2018 CDB-simple_after_LibreOffice.htm<br \/>\n-rw-r--r--    1 owner    group       20624 Jun  4  2015 check-mk-agent.rpm<br \/>\ndrwx------    2 owner    group        4096 May 11  2019 clamav-030407a30e41469e50714e18d06cfef6\/<br \/>\ndrwx------    2 owner    group        4096 Nov 10  2018 clamav-05c7969f7c92127c0a67d1e1e030ff7a\/<br \/>\ndrwx------    2 owner    group        4096 Jun 16  2018 clamav-0c9c5d08dd88487d2db8ab0d89844a98\/<br \/>\n# more follows ...<br \/>\n-rw-------    1 owner    group    20041728 Dec  1 02:32 magick-299501ChMis2EYamN<br \/>\n-rw-------    1 owner    group    31457280 Dec  1 02:32 magick-29950E5FvDZxbZUTb<br \/>\n-rw-------    1 owner    group    31457280 Dec  1 02:33 magick-30009gmKHkoN2pnsz<br \/>\n-rw-------    1 owner    group    31457280 Dec  1 02:32 magick-30011B1tagrDAr7pR<br \/>\n-rw-------    1 owner    group    31457280 Dec  1 02:33 magick-30011VUw-Xwaqo2lT<br \/>\n-rw-------    1 owner    group    31457280 Dec  1 02:33 magick-30043kgDfzEiS4YhO<br \/>\n-rw-------    1 owner    group    31457280 Dec  1 02:34 magick-30089dJLmu7BUm4Cw<br \/>\n-rw-------    1 owner    group    31457280 Dec  1 02:33 magick-30133nUvTOGPaB5XG<br \/>\n-rw-------    1 owner    group    31457280 Dec  1 02:33 magick-30133qaJFxqr0Kbgr<br \/>\n-rw-------    1 owner    group     7234560 Dec  1 02:45 magick-33938vgJrHboBpWeI<br \/>\n-rw-------    1 owner    group    31457280 Dec  1 02:59 magick-36847TC-kxmkRqR4V<br \/>\n-rw-------    1 owner    group    31457280 Dec  1 03:00 magick-36847YUdME4k4jgwh<br \/>\n-rw-------    1 owner    group    31457280 Dec  1 02:59 magick-368918jQfT0gouz5z<br \/>\n-rw-------    1 owner    group    31457280 Dec  1 03:00 magick-36891NSRHciA7uHb8<br \/>\n-rw-------    1 owner    group    31457280 Dec  1 03:00 magick-3707285W0V0oGoH97<br \/>\n-rw-------    1 owner    group    31457280 Dec  1 02:59 magick-37072lAYUvoSex9wk<br \/>\n-rw-------    1 owner    group    31457280 Dec  1 03:00 magick-37073XLevidVmQCPl<br \/>\n# more follows ...<br \/>\n-rw-rw-rw-    1 owner    group       87155 Mar 26  2019 minify_0dca26f4ae4988d406871896dc562350<br \/>\n-rw-rw-rw-    1 owner    group       15260 Mar 26  2019 minify_0dca26f4ae4988d406871896dc562350.gz<br \/>\n-rw-rw-rw-    1 owner    group       85916 Mar 26  2019 minify_2972bf58405bbbc339884b94935eb6bf<br \/>\n-rw-rw-rw-    1 owner    group       17938 Mar 26  2019 minify_2972bf58405bbbc339884b94935eb6bf.gz<br \/>\n-rw-rw-rw-    1 owner    group       12447 Mar 26  2019 minify_67325ffb44e64f839c31db871aa8f6de<br \/>\n-rw-rw-rw-    1 owner    group        2824 Mar 26  2019 minify_67325ffb44e64f839c31db871aa8f6de.gz<br \/>\n-rw-rw-rw-    1 owner    group      185518 Mar 26  2019 minify_f8189fe934d7fecd140658eef38fcf74<br \/>\n-rw-rw-rw-    1 owner    group       34816 Mar 26  2019 minify_f8189fe934d7fecd140658eef38fcf74.gz<br \/>\n-rw-------    1 nobody   root         2227 Apr 25  2014 mNQtmxm4OS<br \/>\n-rw-r--r--    1 owner    group           0 Apr 28  2015 msans.ans<br \/>\n-rwxr-xr-x    1 owner    group         741 Apr 28  2015 msans.ksh*<br \/>\n-rw-------    1 mysql    mysql           0 Jun 19  2018 MYchYpJx<br \/>\n-rw-r--r--    1 owner    group           0 Sep 12  2017 mysocket1337.tmp<br \/>\n-rw-r--r--    1 owner    group         386 Oct 21  2014 no.worries<br \/>\ndrwxr-xr-x    2 owner    group        4096 Oct 21  2014 okold\/<br \/>\n-rw-------    1 owner    group           0 Jan 11  2017 pdfFafOZA<br \/>\n<\/code><\/p>\n<blockquote><p>\nThose magick-* files seem problematic!  Do you think a look around the net would reveal anything useful?\n<\/p><\/blockquote>\n<p>Astounding!  Look at <a target=_blank href='https:\/\/imagemagick.org\/discourse-server\/viewtopic.php?t=23649' title='Useful link, thanks'>what are &#8216;\/tmp\/magick-*&#8217; files? &#8211; ImageMagick<\/a> &#8230;<\/p>\n<blockquote cite='https:\/\/imagemagick.org\/discourse-server\/viewtopic.php?t=23649'><p>\nWhen IM can&#8217;t do its work in main memory, it uses disk. If the process completes normally, the temporary disk files are deleted. If the process fails, these files are often not deleted.<br \/>\n<br \/>\nIf you have no IM processes running, you can safely delete these files.\n<\/p><\/blockquote>\n<blockquote><p>\nKnowing that, and seeing the dates of those problematic \/tmp\/magick-* files, am I right in thinking you&#8217;ll tabulate a short term and long term strategy remedy to the problem?\n<\/p><\/blockquote>\n<p>And do fish swim?!<\/p>\n<table>\n<tr>\n<th>Short term strategy<\/th>\n<th>Long term strategy<br \/>Within ksh shell script that crontab runs each minute, add (allowing 40 minutes before saying the ImageMagick must have failed) &#8230;<\/th>\n<\/tr>\n<tr>\n<td>\n<code><br \/>\n$ rm -f \/tmp\/magick-*<br \/>\n$ df -k \/tmp  # Sanity check gives \"\/usr\/tmpDSK       544256 24428    492180   5% \/tmp\" ... much better<br \/>\n$ curl HTTP:\/\/www.rjmprogramming.com.au\/PHP\/tutorial_options.php<br \/>\n<\/code>\n<\/td>\n<td>\n<code><br \/>\nksh -c 'for i in `find \/tmp -name \"magick-*\" -atime +40m`; do rm -f $i; done'<br \/>\n<\/code>\n<\/td>\n<\/tr>\n<\/table>\n<p>Feel free to see a <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/Mac\/tmp_issue.pdf\" title=\"Click picture\">PDF stream of consciousness<\/a> presentation of us dealing with this issue.<\/p>\n<p><!--p>You can also see this play out at WordPress 4.1.1's <a target=_blank href='\/\/www.rjmprogramming.com.au\/ITblog\/troubleshooting-landing-page-crontab-curl-tutorial\/'>Troubleshooting Landing Page Crontab Curl Tutorial<\/a>.<\/p-->\n<hr>\n<p id='lpmpcct'>Previous relevant <a target=_blank title='Landing Page Mobile Phone Crontab Curl Tutorial' href='\/\/www.rjmprogramming.com.au\/ITblog\/landing-page-mobile-phone-crontab-curl-tutorial\/'>Landing Page Mobile Phone Crontab Curl Tutorial<\/a> is shown below.<\/p>\n<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/\"><img decoding=\"async\" style=\"border: 15px solid pink;\" alt=\"Landing Page Mobile Phone Crontab Curl Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/ephemeral\/landing-30of.jpg\" title=\"Landing Page Mobile Phone Crontab Curl Tutorial\"  style=\"float:left;\"   \/><\/a><p class=\"wp-caption-text\">Landing Page Mobile Phone Crontab Curl Tutorial<\/p><\/div>\n<p>That work with the RJM Programming Landing Page we were last looking at a couple of days ago (with <a target=_blank title='Landing Page Primer Tutorial' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/landing-page-mobile-phone-tutorial\/'>Landing Page Mobile Phone Tutorial<\/a>) was all fine and good, but the introduction of a new HTML <i>indexmobile.html<\/i> for mobile phone usage, specifically, needs melding into existant web server arrangements.<\/p>\n<p>For the most part <i>&#8220;web server arrangements&#8221;<\/i> has little to do with HTML and Javascript, which is usually client side work, unless, perhaps you involve <a target=_blank title='Ajax information from Wikipedia ... thanks' href='http:\/\/en.wikipedia.org\/wiki\/Ajax_%28programming%29'>Ajax<\/a>.<\/p>\n<p>But even ignoring Ajax, and ignoring server side languages like PHP (or ASP.Net) &#8230; remember &#8230;<\/p>\n<blockquote>\n<p>As we continue in this series of tutorials we don&#8217;t pretend to be experts on aesthetics but we will show you some HTML and Javascript (no PHP, deliberately (read <a target=_blank href='https:\/\/www.rjmprogramming.com.au\/ITblog\/linux-sudo-nohup-watchdog-primer-tutorial\/'>Linux sudo nohup Watchdog Primer Tutorial<\/a> to get this in context, for us)) functionality ideas that could supplement some great graphical design ideas you have to start something yourself, perhaps.<\/p>\n<\/blockquote>\n<p> &#8230; from <a target=_blank title='Landing Page Primer Tutorial' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/landing-page-primer-tutorial\/'>Landing Page Primer Tutorial<\/a> &#8230; how can HTML (with its associated Javascript) make use of <i>&#8220;web server&#8221;<\/i> anything much other than being a place it gets stored?<\/p>\n<p>Well, that web server is a server &#8230; a computer &#8230; with its own processes &#8230; ours is a Linux web server <i>&#8220;computer&#8221;<\/i> &#8230; with batch processing capabilities &#8230; easiest to access via <a target=_blank title='crontab' href='http:\/\/www.computerhope.com\/unix\/ucrontab.htm'>crontab<\/a>, and we first talked about how the RJM Programming Landing Page could be supplied with an HTML select element filled with RJM Programming blog tutorials with the most recent ones up the top, via the <i>&#8220;crontab&#8221;<\/i> running of a PHP web application that reads the WordPress MySql database to derive the contents of this HTML select element plonked into the Landing Page when we presented <a title='More on Linux Crontab Curl Tutorial' href='#molcct'>More on Linux Crontab Curl Tutorial<\/a> as shown below.<\/p>\n<p>So here we have a <i>before<\/i> and <i>after<\/i> scenario &#8230; <font size=1>that doesn&#8217;t involve hair nor weight loss<\/font> &#8230; so here is the crontab before (which we&#8217;ll keep but add another similar process onto) combining its talents with PHP and <a target=_blank href='http:\/\/en.wikipedia.org\/wiki\/CURL' title='Curl information from Wikipedia ... thanks'>curl<\/a> &#8230; <font size=1>the &#8220;CC dynamic duo&#8221;<\/font> &#8230;<\/p>\n<p><code><br \/>\n59 23 * * *  curl http:\/\/www.rjmprogramming.com.au\/PHP\/tutorial_options.php 2> \/home\/rjmprogr\/public_html\/PHP\/tutorial_options.bad<br \/>\n<\/code><\/p>\n<p> &#8230; but we need to tell you a great thing about <i>curl<\/i> &#8230; you can access, easily, a single <a target=_blank title='PHP $_GET[] parameter information' href='http:\/\/php.net\/manual\/en\/reserved.variables.get.php'>$_GET[]<\/a> PHP parameter, because Linux doesn&#8217;t think &#8220;?&#8221; is very special (but it does have a &#8220;background process meaning&#8221; for &#8220;&amp;&#8221; making it hard to use <i>curl<\/i> with more than one $_GET[] PHP parameter involved) &#8230; leading us to our new <b>bold<\/b> <i>crontab<\/i> record below to cater for &#8220;indexmobile.html&#8221; updating &#8230;<\/p>\n<p><code><br \/>\n59 23 * * *  curl http:\/\/www.rjmprogramming.com.au\/PHP\/tutorial_options.php 2> \/home\/rjmprogr\/public_html\/PHP\/tutorial_options.bad<br \/>\n<b>57 23 * * *  curl http:\/\/www.rjmprogramming.com.au\/PHP\/tutorial_options.php?mobile=mobile 2> \/home\/rjmprogr\/public_html\/PHP\/tutorial_options.bad<\/b><br \/>\n<\/code><\/p>\n<p> &#8230; and what needed doing with the PHP?<\/p>\n<p>Here is the downloadable PHP programming source code you could call <a target=_blank title='tutorial_options.php' href='http:\/\/www.rjmprogramming.com.au\/PHP\/tutorial_options.php------GETME'>tutorial_options.php<\/a> changed for the purposes of being capable of updating &#8220;indexmobile.html&#8221; as per <a target=_blank title='tutorial_options.php' href='http:\/\/www.rjmprogramming.com.au\/PHP\/Geographicals\/diff.php?one=http:\/\/www.rjmprogramming.com.au\/PHP\/tutorial_options.php------GETME'>this link<\/a>.<\/p>\n<p>The effect on mobile phone usage of the RJM Programming Landing Page tutorial dropdown (HTML select element) list of RJM Programming blog tutorials (updated daily) is seen with today&#8217;s <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/ephemeral\/landing-30of.jpg\">tutorial picture<\/a>.<\/p>\n<hr>\n<p id='molcct'>Previous relevant <a target=_blank title='More on Linux Crontab Curl Tutorial' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/more-on-linux-crontab-curl-tutorial\/'>More on Linux Crontab Curl Tutorial<\/a> is shown below.<\/p>\n<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/More_Linux_Crontab_Curl.jpg\"><img decoding=\"async\" style=\"float:left; border: 15px solid pink;\" alt=\"More on Linux Crontab Curl Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/PHP\/More_Linux_Crontab_Curl.jpg\" title=\"More on Linux Crontab Curl Tutorial\" \/><\/a><p class=\"wp-caption-text\">More on Linux Crontab Curl Tutorial<\/p><\/div>\n<p>Sometimes for a website you only want to do a web server task once or a few times a day, and you, ideally, wouldn&#8217;t want to run into the remote possibility that two people could perform the task at precisely the same time.   This scenario happens often when using server-side languages like ASP.Net and PHP.   If it didn&#8217;t matter that two people might do the same thing at once then you could do the job within your web-based PHP, and you may consider using a date and time test in your web-based PHP to do your &#8220;once or a few times&#8221; task in your PHP.   This latter idea has the advantage that file ownership issues will probably not crop up because the web user will be manipulating any media or HTML files you may be dealing with, rather than the administrator user that will probably be overseeing your &#8220;once or a few times&#8221; <a target=_blank href='http:\/\/en.wikipedia.org\/wiki\/Crontab' title='Linux crontab information from Wikipedia ... thanks'>cron<\/a> job that we show you here today.<\/p>\n<p>So the task today is to keep the rjmprogramming.com.au&#8217;s <a target=_blank title='Landing page of domain rjmprogramming.com.au' href='http:\/\/www.rjmprogramming.com.au'>landing page<\/a> &#8220;Tutorials&#8221; dropdown up to date with the latest blog postings, rather than having to manually attend to this with interactive (HTML code) edits and <a target=_blank title='Web Server Access Primer Tutorial' href='http:\/\/www.rjmprogramming.com.au\/wordpress\/?p=6407'>(s)ftp<\/a> uploads.  You may be wondering why not just write the landing page in PHP, and this is a fair point, but the strategy here at this domain is that the landing page and its &#8220;fellow&#8221; webpages should be independent of MySql, which, under big loads, can go down, and here we use a <a target=_blank title='Watchdog' href='http:\/\/www.rjmprogramming.com.au\/wordpress\/?tag=watchdog'>watchdog<\/a> to fix that, should it happen.   Previously we had a very similar task you can read about with the <a href='#kscj' title='Linux Crontab Curl Primer Tutorial'>Linux Crontab Curl Primer Tutorial<\/a> below.   It is so similar, let&#8217;s use <a target=_blank href='http:\/\/en.wikipedia.org\/wiki\/CURL' title='Curl information from Wikipedia ... thanks'>curl<\/a>, PHP and crontab to do this task like with that previous task.   So this is command line, and this is batch work, but that worry in other types of batch work where you need to worry about where you are as you do any file management, is handled quite well by the wrapping of the job in curl, which takes as its argument a URL, so, implicitly, the place to work with file management, is handled by curl and the PHP we write (specifically where the code uses <i>dirname(__FILE__)<\/i>).<\/p>\n<p>Here is the downloadable PHP programming source code you could call <a target=_blank title='tutorial_options.php' href='http:\/\/www.rjmprogramming.com.au\/PHP\/tutorial_options.php_GETME'>tutorial_options.php<\/a> and you will see, if you examine the code that it is very specific to conditions here at this rjmprogramming.com.au domain, so please be aware of that, but maybe its concepts can help you out with something else you are tackling.  A list of the specifics you would want to address (should you adapt it for your own purposes) include:<\/p>\n<ul>\n<li>the PHP explode methodology (in the code above) assumes there are two select dropdowns (spelt in lowercase) in the underlying HTML code (for rjmprogramming.com.au&#8217;s landing page) we are rewriting, and that it is the second one we update with information gleaned (via SQL query) from the WordPress MySql database the PHP reads (where we piece together a $retval string of the HTML option tags belonging to the <i>tutorials<\/i> HTML select tag)<\/li>\n<li>the MySql database access hostname, username, password, database name, database table name<\/li>\n<li>the Linux web server file owner used during the (commented out) <i>chown<\/i> command you may need to consider to allow the crontab&#8217;s user be able to leave the files owned by the website user<\/li>\n<\/ul>\n<p>PHP commands of interest in today&#8217;s <a target=_blank title='Live run via click picture' href='http:\/\/www.rjmprogramming.com.au\/PHP\/More_Linux_Crontab_Curl.jpg'>tutorial<\/a> include:<\/p>\n<ul>\n<li><a target=_blank href='http:\/\/www.php.net\/manual\/en\/function.file-get-contents.php' title='file_get_contents'>file_get_contents<\/a><\/li>\n<li><a target=_blank href='http:\/\/www.php.net\/manual\/en\/function.file-put-contents.php' title='file_put_contents'>file_put_contents<\/a><\/li>\n<li><a target=_blank href='http:\/\/www.php.net\/manual\/en\/function.dirname.php' title='dirname'>dirname<\/a><\/li>\n<li><a target=_blank href='http:\/\/www.php.net\/manual\/en\/function.chown.php' title='chown'>chown<\/a><\/li>\n<li><a target=_blank href='http:\/\/www.php.net\/manual\/en\/function.explode.php' title='explode'>explode<\/a><\/li>\n<li><a target=_blank href='http:\/\/www.php.net\/manual\/en\/function.str-replace.php' title='str_replace'>str_replace<\/a><\/li>\n<\/ul>\n<p>Maybe it is just me, but liking <i>&#8220;Onion of the 4th dimension&#8221;<\/i> the kind of thinking I gravitate towards is:<\/p>\n<ul>\n<li>supervisory command line arrangements<\/li>\n<li>all &#8220;replace&#8221; type functionality &#8230; to get the problem into a shape suitable for the bits down deeper into the &#8220;core&#8221; of your &#8220;onion&#8221; &#8230; Linux-speak would say <a target=_blank title='Kernel information from Wikipedia ... thanks' href='http:\/\/en.wikipedia.org\/wiki\/Kernel_%28operating_system%29'>&#8220;kernel&#8221;<\/a> of your &#8220;onion&#8221;<\/li>\n<li>parameters and arguments &#8230; continuing on that theme of <i>slotting<\/i> something (the user is specifically interested in, data-wise) in dynamically for something that &#8220;represents&#8221; it in the code &#8230; sort of, like an <a target=_blank title='Interpretive language information from Wikipedia ... thanks' href='http:\/\/en.wikipedia.org\/wiki\/Interpreted_language'><i>&#8220;interpretive&#8221;<\/i><\/a> approach (often people like to say &#8220;scripting&#8221;)<\/li>\n<\/ul>\n<p>Programmers can think in entirely different ways, and if other methods <i>work<\/i> then that is great (woh!) but if they do not <i>work<\/i> for any platform (sometimes you don&#8217;t intend to cater for every platform known to humans and <strike>mangoes<\/strike> &#8230; damn &#8230; was doing so well &#8230; <i>persongoes<\/i>), and these ideas may really irk many programmers, but you need to consider styles of work that suit your way of thinking best.<\/p>\n<p>So, to do this task we wrote new PHP code and cloned the crontab code used in the tutorial below but change the minute of the hour the task is run, and what is run, in crontab on the Linux web server for the domain at rjmprogramming.com.au &#8230; happy studies!<\/p>\n<hr>\n<p id='kscj'>Previous relevant <a target=_blank title='Linux Crontab Curl Primer Tutorial' href='http:\/\/www.rjmprogramming.com.au\/wordpress\/?p=6399'>Linux Crontab Curl Primer Tutorial<\/a> is shown below.<\/p>\n<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/Linux\/curl\/crontab\/\"><img decoding=\"async\" style=\"float:left; border: 15px solid pink;\" alt=\"Linux Crontab Curl Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/Linux\/curl\/crontab\/Crontab_Curl-68of.jpg\" title=\"Linux Crontab Curl Primer Tutorial\" \/><\/a><p class=\"wp-caption-text\">Linux Crontab Curl Primer Tutorial<\/p><\/div>\n<p>Linux (or Unix) is a command line environment that supports interactive and non-interactive task management.   Often non-interactive tasks are known as <a target=_blank title='batch processing' href='http:\/\/en.wikipedia.org\/wiki\/Batch_processing'>batch processes<\/a>, often intended not to rely on any user intervention, unless there is a problem.<\/p>\n<p>Today, in this tutorial (which builds on <a target=_blank title='Linux Background Primer Tutorial' href=\"#lbpt\">Linux Background Primer Tutorial<\/a>), we see the power of combining <a target=_blank title='Curl information from Wikipedia' href='http:\/\/en.wikipedia.org\/wiki\/CURL'>Curl<\/a> under the auspices of crontab to run a webpage piece of functionality once a day at a specified time.<\/p>\n<p>Some CMS systems like Drupal use crontab to perform actions on the database at regular intervals.<\/p>\n<p>For Windows systems you might want to look at Windows Task Schedular for similar functionality.<\/p>\n<p>Linux has several approaches to activating a task, some (not mentioning all the ways one process can <a target=_blank title='fork' href='http:\/\/www.computerhope.com\/jargon\/f\/fork.htm'>fork<\/a> or launch another process) of them being:<\/p>\n<ul>\n<li>interactively (from the command line)<\/li>\n<li>kick off a process from command line, and place in in the background, without supervision, necessarily, via the suffix <i>&amp;<\/i><\/li>\n<li>kick off a process without supervision, necessarily, via <a target=_blank title='crontab' href='http:\/\/www.computerhope.com\/unix\/ucrontab.htm'>crontab<\/a><\/li>\n<li>kick off a process in the background (without supervision, necessarily) via <a target=_blank title='nohup' href='http:\/\/www.computerhope.com\/unix\/unohup.htm'>nohup<\/a><\/li>\n<li>kick off a process from command line, and place it in the background, without supervision, necessarily (and optionally change its state via <a target=_blank title='fg' href='http:\/\/www.computerhope.com\/unix\/ufg.htm'>fg<\/a> and <a target=_blank title='bg' href='http:\/\/www.computerhope.com\/unix\/ubg.htm'>bg<\/a>)<\/li>\n<\/ul>\n<hr \/>\n<p id=\"lbpt\">The previous <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/wordpress\/?p=6077\">Linux Background Primer Tutorial<\/a> is well worth reading below.<\/p>\n<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/Linux\/Background\/\"><img decoding=\"async\" style=\"float:left; border: 15px solid pink;\" alt=\"Linux Background Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/Linux\/Background\/crontab_nohup_fg.jpg\" title=\"Linux Background Primer Tutorial\" \/><\/a><p class=\"wp-caption-text\">Linux Background Primer Tutorial<\/p><\/div>\n<p>Linux (or Unix) is a command line environment that supports interactive and non-interactive task management.   Often non-interactive tasks are known as <a target=_blank title='batch processing' href='http:\/\/en.wikipedia.org\/wiki\/Batch_processing'>batch processes<\/a>, often intended not to rely on any user intervention, unless there is a problem.<\/p>\n<p>In the pre-GUI days batch processes were very prominent, but they still are today, as far as actually getting things done.   It is just that the more glamorous activities pass our notice more, but there are servers out there churning away with batch processes, dreaming of the day when they&#8217;ll work out how they can make that cup of coffee for you in the morning.   And do we ever offer them even a cup&#8217;o&#8217;tea &#8230; it&#8217;s a disgrace, so it is.<\/p>\n<p>Linux has several approaches to activating a task, some (not mentioning all the ways one process can <a target=_blank title='fork' href='http:\/\/www.computerhope.com\/jargon\/f\/fork.htm'>fork<\/a> or launch another process) of them being:<\/p>\n<ul>\n<li>interactively (from the command line)<\/li>\n<li>kick off a process from command line, and place in in the background, without supervision, necessarily, via the suffix <i>&amp;<\/i><\/li>\n<li>kick off a process without supervision, necessarily, via <a target=_blank title='crontab' href='http:\/\/www.computerhope.com\/unix\/ucrontab.htm'>crontab<\/a><\/li>\n<li>kick off a process in the background (without supervision, necessarily) via <a target=_blank title='nohup' href='http:\/\/www.computerhope.com\/unix\/unohup.htm'>nohup<\/a><\/li>\n<li>kick off a process from command line, and place it in the background, without supervision, necessarily (and optionally change its state via <a target=_blank title='fg' href='http:\/\/www.computerhope.com\/unix\/ufg.htm'>fg<\/a> and <a target=_blank title='bg' href='http:\/\/www.computerhope.com\/unix\/ubg.htm'>bg<\/a>)<\/li>\n<\/ul>\n<p>The last four above are often best performed on a shell script, whether that be a <a target=_blank title='bash' href='http:\/\/www.computerhope.com\/unix\/ubash.htm'>Bash<\/a>, <a target=_blank title='korn' href='http:\/\/www.computerhope.com\/unix\/uksh.htm'>Korn<\/a>, <a target=_blank title='bash' href='http:\/\/www.computerhope.com\/unix\/ush.htm'>Bourne<\/a> or <a target=_blank title='bash' href='http:\/\/www.computerhope.com\/unix\/ucsh.htm'>Cshell<\/a> script.   There are some good general tips for batch process scripts:<\/p>\n<ul>\n<li>never assume where you are, rather specify the directory to be in, via <i>&#8220;cd&#8221;<\/i><\/li>\n<li>never assume that the environment variables will be exactly the same as for an interactive session<\/li>\n<li>be more thorough to log errors and log activity to files to see, later, what happened<\/li>\n<li>it is not good to proceed on errors (unless you have set up independent means of checking) because there will be no human to interactively decide that the problem should not stop the job proceeding<\/li>\n<li>pretty obviously, don&#8217;t expect anybody to answer an interactive entry requirement (but you can simulate lots of interactive input via redirected standard input eg. &lt; [filename])<\/li>\n<\/ul>\n<p>Take a look at some example Linux background processing at this <a target=_blank title='tutorial' href=\"http:\/\/www.rjmprogramming.com.au\/Linux\/Background\/\">tutorial<\/a>.  In it you will see some crontab work where the parameters are (as explained <a target=_blank title='crontab explained' href='http:\/\/forums.hostsearch.com\/showthread.php?2693-Crontab-explained'>here<\/a> &#8230; thanks):<\/p>\n<blockquote>\n<p>\nMIN =  Minute 0-60<\/p>\n<p>HOUR = Hour [24-hour clock] 0-23<\/p>\n<p>MDAY = Day of Month 1-31<\/p>\n<p>MON = Month 1-12 OR jan,feb,mar,apr &#8230;<\/p>\n<p>DOW =  Day of Week 0-6 OR sun,mon,tue,wed,thu,fri,sat<\/p>\n<p>COMMAND = Command to be run Any valid command-line\n<\/p>\n<\/blockquote>\n<p>The <i>*\/6 * * * * \/Applications\/MAMP\/htdocs\/pdftoimage.sh<\/i> of our usage runs \/Applications\/MAMP\/htdocs\/pdftoimage.sh every six minutes.<\/p>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d6077' onclick='var dv=document.getElementById(\"d6077\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"http:\/\/www.rjmprogramming.com.au\/wordpress\/?tag=Linux\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d6077' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n<hr \/>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d6399' onclick='var dv=document.getElementById(\"d6399\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"http:\/\/www.rjmprogramming.com.au\/wordpress\/?tag=Linux\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d6399' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n<hr>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d8328' onclick='var dv=document.getElementById(\"d8328\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"http:\/\/www.rjmprogramming.com.au\/wordpress\/?tag=web-server\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d8328' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n<hr>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d20122' onclick='var dv=document.getElementById(\"d20122\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"http:\/\/www.rjmprogramming.com.au\/wordpress\/?tag=curl\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d20122' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n<hr>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d47359' onclick='var dv=document.getElementById(\"d47359\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/troubleshooting\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d47359' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Back earlier in December (2019) the crontab\/curl work of Landing Page Mobile Phone Crontab Curl Tutorial must have been disrupted. Why think that? The RJM Programming Landing Page dropdown of blog tutorial links was missing something &#8230; anyone, anyone? &#8230; &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/troubleshooting-landing-page-crontab-curl-tutorial\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,14,29,37],"tags":[234,249,274,284,1658,3158,680,1105,2296,1313,1319],"class_list":["post-47359","post","type-post","status-publish","format-standard","hentry","category-elearning","category-event-driven-programming","category-operating-system","category-tutorials","tag-command-line","tag-configuration","tag-crontab","tag-curl","tag-imagemagick","tag-ksh","tag-landing-page","tag-script","tag-troubleshoot","tag-troubleshooting","tag-tutorial"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/47359"}],"collection":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/comments?post=47359"}],"version-history":[{"count":5,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/47359\/revisions"}],"predecessor-version":[{"id":48745,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/47359\/revisions\/48745"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=47359"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=47359"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=47359"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}