July 4, 2016

Easy Script to Test your CRON Job

Developers would know this…often times, we setup CRON Jobs to run on specific times to execute a specific file or perform a task but we really don’t know if it’s running as it should.

Now I know many developers choose to have a script that probably logs its execution on a log file somewhere or output it to a TXT file. This is one alternative but I found this little PHP script online on InkPlant. It quite useful because it does the same thing (outputting execution of the main file to a TXT document).

If you are adding a job through crontab, here’s a good way to know if it’s actually running:

1) Create a blank text document named cron_test.txt and upload it into your script’s folder. Change the CHMOD settings or permissions on it to 777 so that its writable by the server.

2) Create a new PHP file called “cron_test.php”. This script will basically execute a task of writing a line of details to cron_test.txt you created in Step 1.

<?php
$crontext = "Cron Run at ".date("r")." by ".$_SERVER['USER']."\n" ;
$folder = substr($_SERVER['SCRIPT_FILENAME'],0,strrpos($_SERVER['SCRIPT_FILENAME'],"/")+1);
$filename = $folder."cron_test.txt" ;
$fp = fopen($filename,"a") or die("Open error!");
fwrite($fp, $crontext) or die("Write error!");
fclose($fp);
echo "Wrote to ".$filename."\n\n" ;
?>

3) Enter the following line to your Crontab or CPanel if you’re using one.

* * * * * php /yourfolder/cron_test.php

4) You should be able to see all the execution data on “cron_test.txt”.

Hope you found that useful. If you have a neater solution to test CRON jobs, please do share. I would love to know about it.

Slither Success Number 1
June 17, 2016

Project Management App on One Side and a Game on the Other

Finding creative ways to waste my time on this incredibly addictive game – Slither.

Warning – DO NOT play the game. As much as I hate snakes, these seem ok. I am Number #1 in the world ending the game with 30,000 points (I think that’s what they call it or 30,000 length). Then, I got a little greedy and crashed into a little one that just started off. I could see how people lose out a lot in this world. All because of their greediness to want more and more.

Lessons – Don’t be greedy and Stop wasting time!

May 26, 2016

Greed…Misery…Blood Shed…Let’s Unite

I’m sorry, but I don’t want to be an emperor. That’s not my business. I don’t want to rule or conquer anyone. I should like to help everyone, if possible, Jew, gentile, black man, white. We all want to help one another. Human beings are like that. We want to live by each other’s happiness — not by each other’s misery. We don’t want to hate and despise one another.

In this world there is room for everyone. And the good earth is rich and can provide for everyone. The way of life can be free and beautiful, but we have lost the way. Greed has poisoned men’s souls, has barricaded the world with hate, has goose-stepped us into misery and bloodshed. We have developed speed, but we have shut ourselves in. Machinery that gives abundance has left us in want. Our knowledge has made us cynical. Our cleverness, hard and unkind. We think too much and feel too little. More than machinery we need humanity. More than cleverness we need kindness and gentleness. Without these qualities, life will be violent and all will be lost.

The aeroplane and the radio have brought us closer together. The very nature of these inventions cries out for the goodness in men, cries out for universal brotherhood, for the unity of us all. Even now my voice is reaching millions throughout the world — millions of despairing men, women and little children — victims of a system that makes men torture and imprison innocent people. To those who can hear me, I say — do not despair. The misery that is now upon us is but the passing of greed — the bitterness of men who fear the way of human progress. The hate of men will pass, and dictators die, and the power they took from the people will return to the people and so long as men die, liberty will never perish.

Soldiers! Don’t give yourselves to brutes — men who despise you — enslave you — who regiment your lives — tell you what to do — what to think or what to feel! Who drill you, diet you, treat you like cattle, use you as cannon fodder. Don’t give yourselves to these unnatural men — machine men with machine minds and machine hearts! You are not machines! You are not cattle! You are men! You have the love of humanity in your hearts. You don’t hate! Only the unloved hate — the unloved and the unnatural!

Soldiers! Don’t fight for slavery! Fight for liberty! In the 17th Chapter of St. Luke it is written: “the Kingdom of God is within man” — not one man nor a group of men, but in all men! In you! You, the people have the power — the power to create machines. The power to create happiness! You, the people, have the power to make this life free and beautiful, to make this life a wonderful adventure.

Then, in the name of democracy, let us use that power! Let us all unite! Let us fight for a new world, a decent world that will give men a chance to work, that will give youth the future and old age a security. By the promise of these things, brutes have risen to power, but they lie! They do not fulfill their promise; they never will. Dictators free themselves, but they enslave the people! Now, let us fight to fulfill that promise! Let us fight to free the world, to do away with national barriers, to do away with greed, with hate and intolerance. Let us fight for a world of reason, a world where science and progress will lead to all men’s happiness.

Soldiers! In the name of democracy, let us all unite!

– Charlie Chaplin

Older Posts