Run a cron command every 15 minutes

Cron is a time based scheduling service on Linux and Unix computers which allows you to run process at specific times for example once a day, once every hour and so on. This brief post looks at how to run a cron command every 15 minutes.

Screen: cannot open your terminal ‘/dev/pts/0’

If you are logged in as a user using “su” or “sudo su” and attempt to use screen, you’ll get the error message “Cannot open your terminal ‘/dev/pts/0’ – please check”. This post shows how to fix this.

Solution 1

Log out of the terminal/SSH session and log back in as the user you want to run screen as instead of using su.

Solution 2

script /dev/null
 screen

Reference

http://serverfault.com/questions/116775/sudo-as-different-user-and-running-screen/116830

This worked for me on Debian 7.8 Wheezy.

Change the default sort order for files and images in SilverStripe

SilverStripe’s File, Folder and Image objects have a default sort of ‘Name’, ‘Sort’ and ‘Name’ respectively, but if you are also using Uncle Cheese’s DataObjectManager the sort order will change to the ‘SortOrder’ field. Unless you’ve been sorting these yourself they’re going to appear in the ImageField control in a more or less random order, which isn’t idea. This post shows the solution.

SilverStripe version used

I have used the methods succesfully in this post with SilverStripe 2.4.5 

Changing the default_sort for ImageField and FileField

In your mysite/_config.php file, add the following:

File::$default_sort = 'Name';
 Folder::$default_sort = 'Name';
 Image::$default_sort = 'Name';

Alternatively make Folder::$default_sort = ‘Sort’ to restore the default behaviour, but I personally prefer to keep it in name order.

Files and Images table

Changing the default_sort as shown above won’t affect the order for the table of files/images in the Files and Images section of the CMS. However the DataObjectManager allows you to change the sort order by clicking the column headings, so it’s not really an issue so much.

However, if you want to make it use the default sort instead, the only way I could work out how to do this myself is to remove the File class from the sortable classes.

In theory, you should be able to do this:

SortableDataObject::remove_sortable_class('File');

But it didn’t work when I tried it because it only removes the extension from the class and doesn’t remove it from the SortableDataObject::$sortable_classes array. You could do this instead, although it’s a but hacky and may have unexpected consequences.

Again, add this to your mysite/_config.php file:

SortableDataObject::$sortable_classes = array();

and then move your existing SortableDataObject::add_sortable_classes declaration below it, if you did already have one.

This will not only make the table now sort in the default_sort, but will remove the useful features of dataobject_manager from the table, so I’d generally advise not to do this; I’m simply showing that it can be done.

Install PHP without Apache on Debian

When you go to install PHP on a Debian server, it will attempt to install a whole bunch of Apache packages instead. This is not very useful if you want to install a different web server, or no web server at all.