Posts Tagged With: time

Watching the disk space

Tagged with: , , , , , ,

If you want to repeat a command many times, for example you are monitoring something, then don’t forget about the watch command. It will print the results of the command to screen every 2 seconds (you can change the interval with -n).


watch --no-title "df -h"

Original Article

No Comments »

Set Time

Tagged with: , , , ,

Set date and time – MonthDayhoursMinutesYear.Seconds


date 041217002007.00
No Comments »

Find New Files

Tagged with: , , , , , ,

Search files created or changed within 10 days


find /usr/bin -type f -mtime -10
No Comments »

Schedule a Download

Tagged with: , , , , , ,

Start a download at any given time


echo 'wget -c www.example.com/files.iso' | at 09:00
No Comments »

Commands for Idle Time

Tagged with: , , , ,

I run this command when I go for lunch or something – these commands take a while to run.


sudo /bin/bash /usr/sbin/makewhatis -w; sudo /usr/bin/updatedb; sudo /home/binnyva/Software/System/chkrootkit-0.47/chkrootkit
No Comments »

Date Command

Tagged with: , , , , ,

Create the MySQL format date(YYYY-MM-DD) using the date command


date +%Y-%m-%d
No Comments »

Find Difference Between 2 Dates in PHP

Tagged with: , , , ,

This function will find the difference between two given times. Does PHP already have a native function for that?


//The difference between 2 given time
function dateDifference($day_1,$day_2) {
	$diff = strtotime($day_1) - strtotime($day_2);

	$sec   = $diff % 60;
	$diff  = intval($diff / 60);
	$min   = $diff % 60;
	$diff  = intval($diff / 60);
	$hours = $diff % 24;
	$days  = intval($diff / 24);
	
	return array($sec,$min,$hours,$days);
}

If you just want the day difference…


$diff = strtotime($day_1) - strtotime($day_2) + 1; //Find the number of seconds
$day_difference = ceil($diff / (60*60*24)) ;  //Find how many days that is

This can be done using the DATEDIFF function in MySQL 5

[tags]php,code,date,difference,time[/tags]

3 Comments »