Drush snippets for Drupal

  • Posted on: 27 June 2013
  • By: Michael

Use, abuse as desired. “alias =” are entries I’ve placed in .bashrc.

drush pml | grep -v Core | grep Enabled -c
alias drush="/home/michael/common/bin/drush/drush"
alias di='drush pmi'
alias dl='drush dl'
alias ds='drush status'
alias dv='drush vget > /home/michael/data/trash/drush-vget`pd`.txt'

Simple Last Access:

alias lastaccess='drush sql-query "SELECT uid, from_unixtime(access, '\''%m/%d %H:%i:%s'\'') as LastAccess, name FROM users ORDER BY access DESC LIMIT 5"'
uid     LastAccess      name
1       08/22 19:11:42  username01
8218    08/16 08:15:44  username02
8330    08/16 08:15:21  username03
8886    08/16 08:15:04  username04
9107    08/16 08:14:37  username05

Last Access on steroids:

alias lastaccess='drush sql-query "SELECT u.uid AS UID, from_unixtime(u.access, '\''%m/%d %H:%i:%s'\'') AS '\''Last Access'\'', u.name AS Name,  SUBSTRING_INDEX(GROUP_CONCAT(DISTINCT r.name ORDER BY r.rid SEPARATOR '\'', '\''), '\'','\'', 3) AS Roles FROM users AS u LEFT JOIN users_roles AS ur ON ur.uid = u.uid LEFT JOIN role AS r ON r.rid = ur.rid GROUP BY u.uid ORDER BY access DESC LIMIT 5"'
UID     Last Access     Name        Roles
8682    08/10 17:27:46  username01  Subscriber, Subscriber: Advanced, Subscriber: Ultimate
1       08/10 17:21:24  username02  administrator
8715    08/10 17:20:04  username03  Subscriber, Subscriber: Advanced, Subscriber: Ultimate
2       08/10 17:14:06  username04  administrator, Test Role
6986    08/10 17:13:06  username05  Subscriber: Demo
alias lastcron='echo `drush vget cron_last --exact | awk '\''{print $2}'\''` | { read a; date -d @$a; }'
alias pd='echo $(date +"%Y%m%d-%H%M%S")'

The last one is used by prior aliases.

Add new comment

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
You know what to do... An image you see? there is one finger less than two hands of items to find. (We sincerely apologize for using image CAPTCHA, hint go low, and bots suck...)
Enter the characters shown in the image.