Latest Posts

New Features in PHP 5.6

New Features in PHP 5.6




  1. Constant Scalar Expressions
  2. Variadic Functions via “…”
  3. Argument Unpacking
  4. ** Shorthand
  5. phpdbg
  6. __debugInfo()
  7. Default Character Encoding
  8. Large File Upload
  9. php://input is reusable
  10. use function and use const



Continue to Read »»»

How to run CronJob in ubuntu using python with log file.

How to run CronJob in ubuntu using python with log file.
Cron is a system daemon used to execute desired tasks (in the background) at designated times.

A crontab is a simple text file with a list of commands meant to be run at specified times. It is edited with a command-line utility. These commands (and their run times) are then controlled by the cron daemon, which executes them in the system background. Each user has a crontab file which specifies the actions and times at which they should be executed, these jobs will run regardless of whether the user is actually logged into the system. There is also a root crontab for tasks requiring administrative privileges.


Using Cron


To use cron for tasks meant to run only for your user profile, add entries to your own user's crontab file. Start the crontab editor from a terminal window: 
Open Terminal Ctrl +Alt +T
Type bellow command

sudo crontab -e

You have seen screen like this 

Use Python

Python file write a sample content and then

*/5 * * * * python /var/www/project_name/python/file_name.py 


Use Log file

Log file should be shown any error may occur open a log file what type of error it is.
a small example given bellow try it.

*/5 * * * * python /var/www/project_name/python/file_name.py >> 
/var/log/log_file_name.log 2>&1


Crontab Options
  • The -l option causes the current crontab to be displayed on standard output.
  • The -r option causes the current crontab to be removed.
  • The -e option is used to edit the current crontab using the editor specified by the EDITOR environment variable.

Crontab Sections:

Each of the sections is separated by a space, with the final section having one or more spaces in it. No spaces are allowed within Sections 1-5, only between them. Sections 1-5 are used to indicate when and how often you want the task to be executed. This is how a cron job is laid out:

  • 30 – 30th Minute
  • 08 – 08 AM
  • 10 – 10th Day
  • 06 – 6th Month (June)
  • * – Every day of the week

Schedule a Job for Every Minute Using Cron.

Ideally you may not have a requirement to schedule a job every minute. But understanding this example will will help you understand the other examples mentioned below in this article.

*/1 * * * * python /var/www/project_name/python/file_name.py 

The * means all the possible unit — i.e every minute of every hour through out the year. More than using this * directly, you will find it very useful in the following cases.

  • When you specify */5 in minute field means every 5 minutes.
  • When you specify 0-10/2 in minute field mean every 2 minutes in the first 10 minute.
  • Thus the above convention can be used for all the other 4 fields.


Crontab syntax:
*    *    *    *    *  command to be executed
┬    ┬    ┬    ┬    ┬
│    │    │    │    │
│    │    │    │    │
│    │    │    │    └───── day of week (0 - 6) (0 is Sunday, or use names)
│    │    │    └────────── month (1 - 12)
│    │    └─────────────── day of month (1 - 31)
│    └──────────────────── hour (0 - 23)
└───────────────────────── min (0 - 59)

- See more at: http://knowledgecornor.blogspot.in/2014/05/cron-job-in-ubuntu-with-php.html#sthash.ei06vda8.dpuf
* * * * * command to be executed ┬ ┬ ┬ ┬ ┬ │ │ │ │ │ │ │ │ │ │ │ │ │ │ └───── day of week (0 - 6) (0 is Sunday, or use names) │ │ │ └────────── month (1 - 12) │ │ └─────────────── day of month (1 - 31) │ └──────────────────── hour (0 - 23) └───────────────────────── min (0 - 59) - See more at: http://knowledgecornor.blogspot.in/2014/05/cron-job-in-ubuntu-with-php.html#sthash.ei06vda8.dpuf
* * * * * command to be executed ┬ ┬ ┬ ┬ ┬ │ │ │ │ │ │ │ │ │ │ │ │ │ │ └───── day of week (0 - 6) (0 is Sunday, or use names) │ │ │ └────────── month (1 - 12) │ │ └─────────────── day of month (1 - 31) │ └──────────────────── hour (0 - 23) └───────────────────────── min (0 - 59) - See more at: http://knowledgecornor.blogspot.in/2014/05/cron-job-in-ubuntu-with-php.html#sthash.ei06vda8.dpuf
* * * * * command to be executed ┬ ┬ ┬ ┬ ┬ │ │ │ │ │ │ │ │ │ │ │ │ │ │ └───── day of week (0 - 6) (0 is Sunday, or use names) │ │ │ └────────── month (1 - 12) │ │ └─────────────── day of month (1 - 31) │ └──────────────────── hour (0 - 23) └───────────────────────── min (0 - 59) - See more at: http://knowledgecornor.blogspot.in/2014/05/cron-job-in-ubuntu-with-php.html#sthash.ei06vda8.dpuf
* * * * * command to be executed ┬ ┬ ┬ ┬ ┬ │ │ │ │ │ │ │ │ │ │ │ │ │ │ └───── day of week (0 - 6) (0 is Sunday, or use names) │ │ │ └────────── month (1 - 12) │ │ └─────────────── day of month (1 - 31) │ └──────────────────── hour (0 - 23) └───────────────────────── min (0 - 59) - See more at: http://knowledgecornor.blogspot.in/2014/05/cron-job-in-ubuntu-with-php.html#sthash.ei06vda8.dpuf
Read more »

gitignore? How to use? and Why?

gitignore? How to use? and Why?
IGNORING FILES IN GIT WITH .GITIGNORE

With Git you are able to define file exceptions to exclude certain files and folders from git repository commits. You can create a files which contains a list of patterns which git will check against on each git add and ignore any matching files.

How to create .gitignore file?

If you create a file in your repository named .gitignore, Git uses it to determine which files and directories to ignore, before you make a commit.
.gitignore file should be committed into your repository, in order to share the ignore rules with any other users that clone the repository.
GitHub maintains an official list of recommended .gitignore files for many popular operating systems, environments, and languages in the github/gitignore public repository.
  1. In Terminal, navigate to the location of your Git repository.
  2. Enter touch .gitignore to create a .gitignore file.
The Octocat has a Gist containing some good rules to add to this file.
If you already have a file checked in, and you want to ignore it, Git will not ignore the file if you add a rule later. In those cases, you must untrack the file first, by running the following command in your terminal:
git rm --cached 

Read more »

Get Latest Tweets Using PHP With Codeigniter

Get Latest Tweets Using PHP With Codeigniter

Twitter API using get Latest tweets(feeds) .

Step 1:  you should read this article understand easily http://lvsclasses.blogspot.in/2013/12/twitter-direct-messages-through.html

step 2:  PHP page write a code like  
example Barak Obama latest tweets here.

Read more »

PHP 5.6.0b2 released!

PHP 5.6.0b2 released!

The PHP development team announces the immediate availability of PHP 5.6.0beta2. As we entered the feature freeze with beta1, this release is almost exclusively a bugfix-only release. All users of PHP are encouraged to test this version carefully, and report any bugs in the bug tracking system.
THIS IS A DEVELOPMENT PREVIEW - DO NOT USE IT IN PRODUCTION!
PHP 5.6.0beta2 comes with a small number of new features, including:
  • Watchpoint support for phpdbg
  • A new fetching mode to mysqlnd which uses less memory but implies more memory copy
For more information about the new features you can check out the work-in-progress documentation or you can read the full list of changes in the NEWS file contained in the release archive.
For source downloads of PHP 5.6.0beta2 please visit the download page. Windows binaries can be found onwindows.php.net/qa/.
complete information click here 
Read more »

Why To Choose PHP In Place Of .Net Or Java?

Why To Choose PHP In Place Of .Net Or Java?
PHP is the fourth popular computer programming language in the world after JAVA, C and VISUAL BASIC. PHP can be used for command-line scripting and client-side GUI applications. It is easy to learn and can be deployed on most web servers, many operating systems and platforms, and can be used with many relational database management systems (RDBMS). PHP is absolutely free of cost as it is open source. It can be embedded with HTML code and is compatible with Apache, IIS, Oracle and Sybase.

Continue to Read »»»

10 THINGS TO DO AFTER INSTALLING UBUNTU 14.04 GET A PERFECT DESKTOP

10 THINGS TO DO AFTER INSTALLING UBUNTU 14.04 GET A PERFECT DESKTOP
Ubuntu 14.04 LTS (Trusty Tahr) will be released tomorrow and since many of you will install it as soon as it's released (or maybe you're already using Ubuntu 14.04), here's a list of 10 useful things to do to get a near perfect desktop. 

Ubuntu 14.04


1. Install Ubuntu AppIndicators (applets) 


Continue to Read »»»

PHP – Best Practises

PHP – Best Practises
There are a number of good practises that you should follow when developing web applications in PHP. Most of these are extremely easy to pick up and some of them will even apply to web application development in general.

1. Redirect after a successful POST request.

This is not PHP-specific. To avoid a situation where the user refreshes their browser and submits the same form data twice, you should always use the Post/Redirect/Get (PRG) pattern. A basic example of this:
Continue to Read »»»

Python

Python

Start python Ubuntu

Ctrl + Alt  + T open Terminal
Type python

>>>   print ("Hellow World")
Hellow World #output

>>> if u exit  Ctrl + D


If you want to create python file

$  gedit  filename.py   (OR)
$  vim    filename.py

Run File

$ python -version filename
 example : $  python3 filename.py




Read more »