Tuesday, March 06, 2018

Running Cron in Drupal 7

I'm having big snags running the Cron task in Drupal 7 via my main host.

Rather than trying to call Cron with wget or lynx (which has resulted in many failures), I found a simple structure is to call cron via Drush, for example:

drush --root=/home/cognimatic/public_html --quiet cron

Either use your cPanel interface to edit Cron tasks or follow the guide at https://www.drupal.org/docs/7/setting-up-cron-for-drupal/configuring-cron-jobs-using-the-cron-command to edit your Crontab. Just make sure Drush can be called from anywhere within your server file structure and you define the root directory (the one that will have index.php and robots.txt etc in it) for your Drupal site.

Just remember you need to have Drush running on your hosting server to use this approach - see https://www.drupal.org/node/2366283 or a previous post on this blog to help you.

Nothing's easy. If it was, everyone would do it.


Monday, August 21, 2017

Installing Drush on Shared Hosting (Vidahost)

I followed the guide at https://www.drupal.org/node/2366283 to install Drush on my current host of choice (Vidahost), but couldn't get Drush to work properly. Problem #1: Couldn't find CLI. Problem #2: Drush 'master' wouldn't work with my many Drupal 7.x sites.

Here's the skinny:
  • First edit your .bashrc file that Vidahost puts in the root folder and make sure the PHP alias is pointing to the CLI version of the PHP release you are using. For Drupal 7 and 8, PHP 5.6 seems to be fine:
    • Type nano .bashrc
    • Remove any aliases to PHP in the file and add the following:
      • alias php='/usr/bin/php-5.6-cli'
    • CTRL + x to save and exit the file
    • Type source .bashrc to reload your Bash file and set up the alias.
  • Install Composer in your root folder
    • curl -sS https://getcomposer.org/installer | php
    • Leave files where they are (leaves lots of files in root, but park that OCD for a change).
  • Type nano .bash_profile to add an alias:
    • alias composer="'/usr/bin/php-5.6-cli' ~/composer.phar"
    • This adds an alias to the PHP 5.6 CLI location on Vidahost - may well work for other hosts too.
  • Save your file (ctrl-X) then run your Bash file with source .bash_profile
  • Get Drush (version 8 works with Drupal 6, 7 & 8) 
    • composer global require drush/drush:8.x
  • Update your .bash_profile with another alias
    • alias drush="~/.composer/vendor/bin/drush"
  • Reload Bash file:
    • source .bash_profile
  • Type drush to see if things are working.
Fame and fortune await (etc).

Thursday, June 26, 2014

I hate VIM

Vim to me will always mean the household cleaner: but in the geek world of sysadmin... well, I'm sure it makes beginners scream too.

Like everything there are a few basics that never seem intuitive, so always have to root them out. So here's the most basic commands for server admin heaven:

i insert mode
ESC back to command mode
:q Exit
:w Write
:qa! Quit and abandon changes

h moves the cursor one character to the left.
j moves the cursor down one line.
k moves the cursor up one line.
l moves the cursor one character to the right.
0 moves the cursor to the beginning of the line.
$ moves the cursor to the end of the line.
w move forward one word.
b move backward one word.
G move to the end of the file.
gg move to the beginning of the file.
`. move to the last edit.

d starts the delete operation.
dw will delete a word.
d0 will delete to the beginning of a line.
d$ will delete to the end of a line.
dgg will delete to the beginning of the file.
dG will delete to the end of the file.
u will undo the last operation.
Ctrl-r will redo the last undo.