Insert time in mysql using now()

Simple way to insert time information in mysql is using now()

now() will automatically insert appropriate depends on type, let say we have field in mysql database in these format :

1. birth (date), now() will insert current date, ex: 2007-05-02

2. birth (datetime), now() will insert current date + current time, ex : 2007-05-2 22:54:30

3. birth (time), now() will insert only time information, ex : 22:54:30

this snippet will get same result with now()

$birth=date(‘Y’).’-‘.date(‘m’).’-‘.date(‘d’); // will be same as 2007-05-02

example in mysql command line :

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\Administrator>cd c:\appserv\mysql\bin

C:\AppServ\mysql\bin>mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.� Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 4.0.24-nt

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.

mysql> create database test;
Query OK, 1 row affected (0.03 sec)

mysql> use test;
Database changed
Continue reading

cvs, cvsup, portsnap and csup

Progress in *BSD world is very fast, everyday patch released, program update etc

to get that update via internet FreeBSD provide a few tools :

  • cvs, not so familiar for beginner
  • cvsup, very famous in FreeBSD, can update ports, source even for backup purpose
  • portsnap, only for port update, in FreeBSD tree since 6.0
  • csup, cvsup alternative, already integrated in 6.2 tree, no need to install, compatible with cvsup

example for cvs :

cvs -z3 -d :pserver:[email protected]:/cvs co -P freesbie2

will fetch freesbie2 and located in current directory where command issued

example for cvsup :

cvsup -g -L2 ports-supfile -h

will update ports information

example for portsnap :

portsnap update

will update ports data, faster than portsnap extract

csup example :

cvsup -g -L2 stable-supfile -h

will update stable source

P.S :

make sure port 5999/tcp open for cvsup and csup

portsnap will use port 80

in Unix | 149 Words

find your program with “whereis”

Many linux distro build nowadays, each distro came with spesific purpose, server, workstation or desktop orientation but still not forget to give access to shell :-)

people who run “ifconfig” in mandriva will get confuse when run same command in fedora or maybe slackware

“command not found” is common message

just use “whereis” command for this purpose :

whereis ifconfig

whereis perl

whereis sh

answer will show up for full path of program

type full path in shell to get same result, not easy but always work :-)

Recreate FreeBSD ports build option

As big fan of FreeBSD ports, I like to play around with ports option, like when installing php4 I was prompted with a lot of build options :

kongja# whereis php4
php4: /usr/ports/lang/php4
kongja# cd /usr/ports/lang/php4

then this ncurse option will popup


===> Found saved configuration for php4-4.4.6
===> Extracting for php4-4.4.6

Continue reading

in Unix | 313 Words

View crontab entries of entire user in FreeBSD

Cron is special utility that process command in periodic time such ;

  • doing regular backup every night
  • email special report every week
  • etc

cron access can be usefull but sometime not, depend on the command issued.

As super user we can list all of entire user crontab entries using log locate in /var/log

su-2.05b# tail -f /var/log/cron
Apr 30 20:30:00 erau /usr/sbin/cron[81893]: (root) CMD (/usr/libexec/atrun)
Apr 30 20:30:00 erau /usr/sbin/cron[81894]: (root) CMD (/usr/local/bin/php /usr/local/share/cacti/poller.php > /dev/null)
Apr 30 20:35:00 erau /usr/sbin/cron[84459]: (root) CMD (/usr/local/bin/php /usr/local/share/cacti/poller.php > /dev/null)
Apr 30 20:35:00 erau /usr/sbin/cron[84462]: (root) CMD (/usr/libexec/atrun)
Apr 30 20:40:00 erau /usr/sbin/cron[87061]: (root) CMD (/usr/libexec/atrun)
Apr 30 20:40:00 erau /usr/sbin/cron[87062]: (root) CMD (/usr/local/bin/php /usr/local/share/cacti/poller.php > /dev/null)
Apr 30 20:45:00 erau /usr/sbin/cron[90181]: (root) CMD (/usr/local/bin/php /usr/local/share/cacti/poller.php > /dev/null)
Apr 30 20:45:00 erau /usr/sbin/cron[90180]: (root) CMD (/usr/libexec/atrun)
Apr 30 20:50:00 erau /usr/sbin/cron[93304]: (root) CMD (/usr/libexec/atrun)
Apr 30 20:50:00 erau /usr/sbin/cron[93305]: (root) CMD (/usr/local/bin/php /usr/local/share/cacti/poller.php > /dev/null)

pay attention on (root) entries, that mean user who run that command in this case generate data for cacti.

You can run the command as root or sudo, otherwise you’ll get “permission denied” message

-bash-2.05b$ tail -f /var/log/cron
tail: /var/log/cron: Permission denied
-bash-2.05b$ su
kongja# tail -f /var/log/cron
Apr 30 20:36:00 kongja /usr/sbin/cron[81442]: (root) CMD (/usr/local/bin/pfstat -q >>/var/log/pfstat)
Apr 30 20:37:00 kongja /usr/sbin/cron[81504]: (root) CMD (/usr/local/bin/pfstat -q >>/var/log/pfstat)
Apr 30 20:38:00 kongja /usr/sbin/cron[81567]: (root) CMD (/usr/local/bin/pfstat -q >>/var/log/pfstat)
Apr 30 20:39:00 kongja /usr/sbin/cron[81631]: (root) CMD (/usr/local/bin/pfstat -q >>/var/log/pfstat)

happy viewing 🙂

P.S :

other usefull place to check for cron entries


in Unix | 343 Words