MX on Linux: Difference between revisions

From Cumulus Wiki
Jump to navigationJump to search
m (→‎Technical users - optional edit to "[Unit]" section: Discovered that <pre> does not work within bullets!)
 
(35 intermediate revisions by 3 users not shown)
Line 1: Line 1:
<big>This page needs further contributions, can you help?</big>
{{Template:WorkInProgressBanner}}

=Are you on the right Wiki page?=

{{Template:Version badge Mx}}'''This page focuses on aspects of MX that are specific to the Linux operating systems.'''

If you are running MX on on any computer running the Microsoft Windows Operating System, then you should be reading the [[MX on Windows OS]] page instead.


==Device Coverage==

Linux is available based on a multitude of different kernels (the building block for the operating system), on a multitude of devices.

This page has been originated by a contributor using the Raspberry Pi Operating System (this is based on Debian, one of the Linux kernels). Be aware therefore that some instructions on this page are specific to a [[Raspberry Pi computer page|Raspberry Pi computer]] with its default operating system.

For other devices, the inclusion of the correct instructions is totally dependent on whether any contributor has edited this page to cover your device in the context of that section of this page. It is hoped that contributions to this page will be made by Cumulus users with a range of different devices so this page is useful to more people.

:Until somebody creates a separate page for Apple Mac computers (that could be a good idea, as there are some significant differences), this page is the best source of advice.


=For those using Raspberry Pi computers=

As described [[Raspberry Pi computer page|on this Raspberry Pi computer Wiki page]], there are significant advantages in using a Raspberry Pi computer to run Cumulus MX, such as it being simple to use, it saving energy costs, and it avoiding the dreaded regular rebooting by Microsoft's Windows Update.

You have two choices:

CHOICE ONE: ‘’’Create a micro-SD card that has everything on it to load a kernel onto your RPi computer and run MX’’’

The developer has created [[Software#Raspberry_Pi_Image|an image you can download]] for those prepared to run two computers (a RPi for actually running MX and another computer for all interactions with MX).

That image contains:
#Raspberry Pi Lite Operating System as kernel (no graphical user interface, designed for a RPi without keyboard or monitor)
#Mono-complete package
#Cumulus MX package

* If you are new to MX, after booting from image, you will need to use the other computer to access the Wizard in the [[MX_Administrative_Interface#Station_Settings|admin interface]]; this will define station type, your choice of units, and some other settings, before MX can start recording data from the connected weather station.
* If you are migrating from another computer, after booting from image, you need to add (using an external memory stick or file transfer from your other device to the RPi), the following:
** (mandatory) [[Cumulus.ini]],
**(optional) [[strings.ini]],
**(mandatory) all files from old [[Data_folder|data sub-folder]],
**and any (optional) files from old [[Reports folder|Reports sub-folder]].

If you want to pursue that approach, please read [[Raspberry_Pi_Image]] page, instead of continuing to read this page. Obviously, you can return to this page on another day if you want to learn more.

CHOICE TWO: ‘’’Load the software packages individually’’’

Please read on, this page will tell you all you need to know.


{{TOCright}}
=Page Content=

This page:
* describes the options available for installing the 3 Cumulus packages:
** CumulusMX.exe
** ExportToMySQL.exe
** CreateMissing.exe
* describes the pre-requisite '''MONO''' software needed to run the various Cumulus executables, how to add the Mono repository to your system, and how to upgrade MONO
* explains how to run Cumulus MX either interactively or as a service
* briefly indicates instructions for configuring MX using the administrative interface
* explains the few key Linux commands it uses
* the content tries to compromise between three types of readers:
** to be useful to anyone who has never used MX (regardless of their previous Linux experience)
** to assist anyone who knows Cumulus, but has not run MX on Linux before
** to add a little technical information for those who wish to tailor their Cumulus MX operation
* describes the optional parameters you can add when starting MX
* briefly explains how to use the other executables

There are various related pages to get more information:
*If you encounter a problem when running MX, please see [[What to do when I have a problem with MX]]
*If MX gives you a message saying "you are not running the latest version", please see [[Updating_MX_to_new_version|Guide to upgrading MX]]
*If you are puzzled by the terminology, please see [[:Category:Terminology]] for links to pages that explain terminology used by Cumulus (these pages were written for the legacy Cumulus 1 and may need updating for MX)
*If you need to know more about files in the installation, please see [[:Category:Cumulus Files]] for links to all Wiki pages describing the sub-folders and files used by MX
*Go to [[:Category:Cumulus MX]] for links to all pages in this Cumulus Wiki that relate specifically to MX
*[[MX Administrative Interface|Admin interface]] provides information on configuration and web pages for viewing your weather data locally
*The [[Cumulus MX FAQ]] page was created with snippets from the forum, but nobody has yet sorted this out into a useful page or updated it for recent releases
*If you were using the original (now legacy) Cumulus software, please read [[Migrating_from_Cumulus_1_to_MX]], although that is mostly directed at those using MX on the same Windows PC as they used for Cumulus 1, and was written for an old MX release, it will help you understand configuration differences.
*If you want to use a script language, you might want to read [[PHP|PHP Hypertext Pre-processor and JavaScript]] page

=Using MX on UNIX-derived Operating Systems=
=Using MX on UNIX-derived Operating Systems=
[[Category:Cumulus MX]]

MX runs on any UNIX-derived operating systems (OS):
MX runs on any UNIX-derived operating systems (OS):
* including those found on Apple Mac computers,
* including those found on Apple Mac computers,
Line 90: Line 10:




==What do people think about MX on Linux?==
==Why install MX on Linux?==


Contributions to the [https://cumulus.hosiene.co.uk/viewforum.php?f=40 Cumulus Support Forum] suggest that:
Contributions to the [https://cumulus.hosiene.co.uk/viewforum.php?f=40 Cumulus Support Forum] suggest that:
*Use on a Raspberry Pi (RPi) computer is very popular
*Use on a Raspberry Pi (RPi) computer is very popular
*In general, people find installing, and running, MX on Linux is easy
*In general, people find installing, and running, MX on Linux is easy
*The few people who do have difficulties are those who have good knowledge of Microsoft systems and feel scared to swap to something different.
*The few people who do have difficulties are those who have good knowledge of Microsoft systems and therefore are so convinced they cannot cope with a swap to something different, that they give up too easily!


Microsoft has had a deliberate policy of being different to traditional computers (all others are mostly based on UNIX). This is why this Wiki gave up attempting to have one page covering MX regardless on which operating system was used, instead creating this page, and the [[MX_on_Windows_OS|Running Cumulus MX on Microsoft Windows]] page with very little duplicated text.
Microsoft has had a deliberate policy of being different to traditional computers (all others are mostly based on UNIX).


You may know that this Wiki started with a single page covering MX regardless on which operating system was used, that did not work.
In the Cumulus support forum, there are many posts from people who are struggling with MX on PCs. It appears this is not because Microsoft computers are so more readily available and therefore known about; but because people often find “installing”, and using, MX is more difficult when using Microsoft Windows.


If you are running MX on on any computer running the Microsoft Windows Operating System, then you should be reading the [[MX on Windows OS]] page instead. In the Cumulus support forum, there are many posts from people who are struggling with MX on PCs. It appears this is not because Microsoft computers are so more readily available and therefore known about; but because people often find “installing”, and using, MX is more difficult when using the more complex Microsoft Windows operating system, and people tend not to understand basic issues such as avoiding "Program Files".


= Do you have a Operating System? =


{{Template:Version badge Mx}}'''This page focuses on aspects of MX that are specific to the Linux operating systems.'''
New hardware might come preloaded with an operating system, or might allow you to choose which operating system to install on it.


Still believe it will be too complex for you? The developer has created [[Software#Raspberry_Pi_Image|an image you can download]] for those prepared to run two computers (a RPi for actually running MX and another computer for all interactions with MX). Read all about it, on [[Raspberry_Pi_Image]] page, and decide if that is for you.
Please see [[Raspberry Pi computer page]] if you want guidance on choosing which model to buy and how to install an operating system on those computers, so you are ready to install MX.


==Device Coverage==
=Do you know how to install packages?=


Linux is available based on a multitude of different kernels (the building block for the operating system), on a multitude of devices.
This is one of several places on this page where a novice can skip on to step-by-step instructions (in this case continue reading at [[#Cumulus packages]]), but others may want to read a little technical detail to understand what they are doing.


This page has been originated by a contributor using the Raspberry Pi Operating System (this is based on Debian, one of the Linux kernels). Be aware therefore that some instructions on this page are specific to a [[Raspberry Pi computer page|Raspberry Pi computer]] with its default operating system.
Read on for a short technical digression to explain the commands for how to install and update software packages (the same commands can be used to install software for [[Your_Own_Server]], or to read the SQLite databases used by MX [[Cumulusmx.db]] and [[Diary.db]]).


For other devices, the inclusion of the correct instructions is totally dependent on whether any contributor has edited this page to cover your device in the context of that section of this page. It is hoped that contributions to this page will be made by Cumulus users with a range of different devices so this page is useful to more people.
==The various components to commands for installation==


:Until somebody creates a separate page for Apple Mac computers (that could be a good idea, as there are some significant differences), this page is the best source of advice.
Linux computers have a “source list” which references the repositories from which software packages can be installed.


==Further Information==
If a particular package can not be found in repositories already in the source list, then another repository can be added to the source list.


There are various related pages to get more information:
===sudo===
* If you encounter a problem when running MX, please see [[What to do when I have a problem with MX]]
* If MX gives you a message saying "you are not running the latest version", please see [[Updating_MX_to_new_version|Guide to upgrading MX]]
* If you are puzzled by the terminology, please see [[:Category:Terminology]] for links to pages that explain terminology used by Cumulus (these pages were written for the legacy Cumulus 1 and may need updating for MX)
* If you need to know more about files in the installation, please see [[:Category:Cumulus Files]] for links to all Wiki pages describing the sub-folders and files used by MX
* Go to [[:Category:Cumulus MX]] for links to all pages in this Cumulus Wiki that relate specifically to MX
* [[MX Administrative Interface|Admin interface]] provides information on configuration and web pages for viewing your weather data locally
* The [[Cumulus MX FAQ]] page was created with snippets from the forum, but nobody has yet sorted this out into a useful page or updated it for recent releases
* If you were using the original (now legacy) Cumulus software, please read [[Migrating_from_Cumulus_1_to_MX]], although that is mostly directed at those using MX on the same Windows PC as they used for Cumulus 1, and was written for an old MX release, it will help you understand configuration differences.
* If you want to use a script language, you might want to read [[PHP|PHP Hypertext Pre-processor and JavaScript]] page
* If you will be using the standard web pages (from release 3.10.1) see [[New_Default_Web_Site_Information|this page]]
* If you want to write your own customised templates, read [[Customised_templates]].
* If you want to explore alternative web pages from third-parties, start [[:Category:User Contributions|on User Contributions page]].


By default, a Linux user should log in as a default user with limited rights.


For example, the Raspberry Pi Operating System has a single default user "Pi", with their home folder that can be referenced as "~".


=Preparing your computer for installing the Cumulus MX suite=
The limited rights mean that a standard user cannot even see (read) some files, cannot execute some commands, and cannot edit (write to) some files. For full access to files, the <code>sudo</code> instruction gives you (just for the command that follows) the same read/write/execute access that the system root user has.


Please see [[Preparing your Linux computer for MX]] page if you have not installed MX on Linux before.
For software packages, the command to be used is <code>apt</code> to invoke the package manager, followed by an "action" and then optionally by the "package name". In that context the default user's limited rights allow use of actions that just read (such as '''search''', ''show''). However, for any action involving writing (such as '''install''', ''full-upgrade'', '''update''', ''autoremove''), the package manager needs additional rights, and we prefix the "apt" with '''sudo'''.


That page covers:
: Elsewhere on this page you might notice [[#Running any MX executable with a terminal session left open|'''cd''']] can move round the file structure (without a "sudo"), but "sudo" is used with [[# Installing/Configuring the MX service and the -service parameter|'''cp''']] as that writes a file.
* [[Preparing your Linux computer for MX#Operating systems|Installing Operating Systems]]
* Package manager
** [[Preparing your Linux computer for MX#Interactive Package management on RPi|Interactive version]]
** [[Preparing your Linux computer for MX#Using Package Manager in terminal mode|Terminal version]]
** [[Preparing your Linux computer for MX#The various components to commands for installation|Commands]]
* [[Preparing your Linux computer for MX#USB HID|Human Interface Devices]]
* [[Preparing your Linux computer for MX#Installing Mono instruction|'''Installing Mono''']]
* [[Preparing your Linux computer for MX#Moving from Microsoft Windows to Linux|Preparing Microsoft Windows files for Linux]]
* [[Preparing your Linux computer for MX#File Names & Paths|Guide to file names and paths]]


Novice readers were advised to skip this part of this Wiki page. That is because everyone should exercise caution before using "sudo", changing folder/file ownership, adding write rights, and even using "-R" or "-y" flag. The use of "sudo" makes it very easy to inadvertently do the wrong action, in the worst case making your computer unusable because it can delete vital folders/files because of something as simple as a typo.


: '''For technical readers only''', "sudo" is further explained later [[#su_and_sudo]]).


Please be advised some of the above is rather technical reading, but ''Mono is required to run the Cumulus packages'' described next. So do ensure that you installed Mono before continuing.
===apt===


==Technical aside==
The second part of any software installation command is “apt” meaning “Advance Package Tool”. In simple terms, it runs the “package manager” used in Linux.


Please note this Wiki page talks about "folders" for compatibility with the [[MX on Windows OS]] page, but Linux prefers to call them directories.
If you are looking online for a tutorial on how to install packages, you might see “apt-get” or "apt-cache" used in examples they quote. Don't copy those examples directly, it should be safe to replace these older package managers with "apt". I have included [[#Package Manager – a brief technical aside|a little technical explanation]] at the end of this page if this really worries you.


Linux has a well defined filesystem, represented as a hierarchic tree starting at the root "/", that is divided into directories (one of which will be "/boot" and hold the kernel), each of those first level directories can be divided into second level directories, this second level is sometimes referenced to as defining the "scope", an indication that each is meant to be used for a specific purpose. The scope can be sub-divided again at lower levels representing "categories" (categories cover items like binary code, documentation, configuration, hardware, source code, runtime and content), and at a lower level still "applications" (i.e. related to specific programs) with further sub-levels for various options within those applications. Many Linux distributions will use logical links so references to a directory at one level in the hierarchy will actually redirect to files in a different directory, this might be because different programs expect to see files in different places or just to enforce ownership and writing rights.
===install===


For the purposes of this Wiki, the terminology "operating system" is used for the whole Linux distribution, you will find that Linux technical people prefer to talk about Linux distributions including:
The third part of our installation instruction is the action parameter. In our current context this is “install”, which tells our package manager what we are trying to do.
# a "kernel" for the underlying handling of files, network and so on;
# one or more "shell" components for the handling of commands entered in terminal mode, including those that run programs (whether included in distribution or added later);
# an optional graphical user interface for simpler access to commands and programs.


For simplicity the terminology "terminal" is used for how you access the shell, this term refers to seeing the command prompt if your Linux is running without a graphical user interface, or to a window that you can open within the graphical interface where commands can be typed. Depending on your Linux, that window might be called "Terminal", "Konsole", "xterm", "gnome-terminal", "uxterm", or even something else. If you are accessing your Linux computer over a network from a computer running Microsoft Windows, then again you may encounter a number of terms for how to access the shell on your Linux computer, "Command Window", "Windows Powershell", or "Windows Terminal". Equally you may use software that calls it a teletype mode, e.g. PuTTY software.
Here is full list of what can follow “apt”, as we will use some of the alternatives later:


=Cumulus packages=
{| class="wikitable" border="1"
|-
!style="width:30px" | Instruction following “apt”
!style="width:300px" | Description
|-
! scope="row"|install
|To install a package and its dependencies
|-
! scope="row"|update
| The "source list" [[#The various components to commands for installation|mentioned earlier]] that references the repositories from which software packages can be installed, needs to be updated periodically so it reflects any changes within those repositories. The instruction "update" is included after "apt" to make sure your computer has up to date information about repositories installed, and to report if these contain packages that can be upgraded
|-
! scope="row"|upgrade
| Once your "source list" is up to date, <code>sudo apt upgrade</code>, followed by a package name, will for the named packages download any newer versions now available in repositories. If you include <code>-y</code> flag, or you answer 'Y' or 'y' to the prompt, then the package manager will continue, and actually replace those packages that are already installed on your computer with the downloaded newer versions, making them available for immediate use. (You cannot upgrade the actual kernel within the operating system with this instruction, so there is no necessity to reboot your Linux computer).
|-
! scope="row"|full-upgrade
| Once your "source list" is up to date, the instruction "full-upgrade" can be included after "apt". The advantage of "full-upgrade" over the simple "upgrade" is that it picks up dependencies, it ensures that every package is able to work with all other packages, and so normally results in more components being upgraded. (Again, this does not affect kernel, and does not require a computer reboot).
|-
! scope="row"|autoremove
| The instruction "autoremove" can be included after "apt" to check all components in the packages you have installed onto your computer, and remove any components that are not needed by the dependencies of the packages you are using. A download for software frequently includes some components specifically for their software to work with particular other optional packages, and therefore installs more than you actually need.


* This section covers:
When we install mono-complete later, the other packages we install do not need every component that has installed, and “autoremove” can be used to tidy up when all our installations are finished.
** CumulusMX.exe
|-
** ExportToMySQL.exe
! scope="row"|remove
** CreateMissing.exe
|If you want to remove just one component manually, use <code>sudo apt remove</code> followed by the name of component you no longer want
|-
! scope="row"|purge
| To remove any installed package and delete all related configuration files, use <code>sudo apt purge</code> then the name of the package we no longer want
|-
! scope="row"|search
|To search in repositories in source list for a package you specify after <code>apt search</code>
|-
! scope="row"|show
|To show any information available about a package that you name after the <code>apt show</code>
|}

=== Flags ===

The basic syntax is either one or two hyphens, followed by one or two letters (each letter has to be a specific case). Various examples will be seen on this page, but here just one is explained here.

If we selected "install" or "upgrade" to follow "apt", we can add a “-y” flag to signify that we want the install to not only down load new components but also install them. Without this flag, the package manager will ask periodically if we want it to continue, and we have to then respond with a “y” each time. For example, when we ask to install a package, "apt" will do a search, it will list what components it has found, and output how big their demands are on storage, without "-y" flag, it will then ask (at least once) if it is okay to continue to installing.

=== Name ===

The final part of the package command is the name of the package or component that we want to install/upgrade/purge/show/remove or search for.

=Install starts here=

If your computer has the pre-installed image, or you have installed MX before, you can skip the sub-sections that follow on here and continue reading at [[#Cumulus packages]].

== Preparing for an install==

Before we do an install of a new package, we typically use this series of commands to ensure our computer is in the best state to work out dependencies of what we are about to install:

:<code>sudo apt update</code>

:<code>sudo apt -y full-upgrade</code>

:<code>sudo apt autoremove</code>

Each of those can be understood from information in [[#install|earlier sub-section]].

If you are installing onto a Pi zero, or similar slow computer, please ensure the size of the swapfile is as big as possible, as the mono-complete we will install is large. In linux, we type <code>free -m</code> to see our RAM size and our swapfile size.

To change swapfile size on the Raspberry Pi (''Can contributors add details for other Linux computers''):
# Edit a file <code>sudo nano /etc/dphys-swapfile</code>.
# Move the cursor down line by line until it reaches '''CONF_SWAPSIZE=100'''. That is showing that the swapfile is only 99 mb by default in the Raspberry Pi Operating System.
# Now move the cursor to the 100, and change it to "512" which is enough for mono even on a Pi zero.
# Next, stop, and restart, the relevant service using <code>sudo /etc/init.d/dphys-swapfile stop && sudo /etc/init.d/dphys-swapfile start</code>.
# That should complete quickly, and we can type <code>free -m</code> again to see the 99 we saw previously has been replaced by 511.

The actual swapfile size to choose depends on the amount of RAM installed on your computer, if you want to know more (because there is some conflicting advice), then do an online search to discover the RAM size on your device and the advice on suitable swapfile size.

=== USB HID ===

There is one more prerequisite package for MX with some weather station types.

You may notice [[MX_Basic_info#HidSharp.dll|HidSharp.dll]] in same folder as executable, this is a cross-platform [https://www.nuget.org/packages/HidSharp/ Universal Serial Bus (USB) Human Interface Device (HID) library].

To check your USB devices, type <code>sudo lsusb -t</code>.

MX uses this library for weather stations (like Fine Offset and USB connected Oregon Scientific models) that appear as a HID via a USB connection. To check if your weather station appears as a HID, download this [https://cumulus.hosiene.co.uk/download/file.php?id=11414 USB HID test package] and run it.

This HidSharp library calls a package ''libudev shared library'' file called ''libudev.so.1''. Most recent Linux distributions will already include the libudev shared library. On my Raspberry Pi, [[#install|typing]] <code>apt search libudev</code> showed ''libudev.so.1'' was already installed. If it is missing, then [[#install]] it.

Optionally, read about [https://cumulus.hosiene.co.uk/viewtopic.php?f=39&t=14310&p=111593&hilit=libudev.so.1#p111593 Oregon Scientific] issues.

Optionally, read about [https://cumulus.hosiene.co.uk/viewtopic.php?p=107913#p107913 Fine Offset] issues, and the optional symbolic file link instructions (those apply if you only have an earlier libudev shared library version, and wish MX to use that).

== Checking if mono-complete in Source List ==

The "source list" [[#The various components to commands for installation|mentioned earlier]] may not contain all the repositories we need for our installations.

Consequently, [[#The_various_components_to_commands_for_installation|type]] <code>apt search mono-complete</code>, to find out whether the mono package is available from one of the repositories already in our source list, and if the version available is compatible with MX (Release announcements for MX should specify which versions of Mono will work).

If mono-complete is not available (or only available in an older version incompatible with MX), then we have to add a new repository, and the one to add depends on which Linux kernel is used by our Operating System.

There are a number of sub-sections below, please check which applies to you, and only read that one.

===Add the Mono repository for a Raspberry Pi===

The two Mono repositories listed here are specific to the 2017 and 2019 releases (respectively) of the operating system for a Raspberry Pi computer. These are taken from [https://www.mono-project.com/download/stable/#download-lin-raspbian download-lin-raspbian]. If your Rasberry Pi is running the 2021 release (11 = Bullseye), or whatever is available when you are reading this page, please refer to that external link for more recent instructions.

# the first line (in each case) installs a certificate
# the echo line defines a repository to add to the sources list.
{| class="wikitable"
|-
! scope="col" style="width:450px; color:blue;padding:8px 14px;font-size:16px;" | Raspberry Operating System 9 (stretch) !! scope="col" style="width:450px; color:navy;padding:8px 14px;font-size:16px;" | Raspberry Operating System 10 (buster)
|-
| style="height:50px;padding:14px;font-size:16px;"| <nowiki>sudo apt install apt-transport-https dirmngr gnupg ca-certificates</nowiki> || style="padding: 0 14px;font-size: 16px;" |<nowiki>sudo apt install apt-transport-https dirmngr gnupg ca-certificates</nowiki>
|-
| style="height:100px; padding: 0 14px;font-size: 16px;" | <nowiki>sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF</nowiki> || style="padding: 0 14px;font-size: 16px;" |<nowiki>sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF</nowiki>
|-
| style="height:100px; padding: 0 14px;font-size:16px;"| <nowiki>echo "deb https://download.mono-project.com/repo/debian stable-raspbianstretch main" | sudo tee /etc/apt/sources.list.d/mono-official-stable.list</nowiki> || style="padding: 0 14px;font-size: 16px;" |<nowiki>echo "deb https://download.mono-project.com/repo/debian stable-raspbianbuster main" | sudo tee /etc/apt/sources.list.d/mono-official-stable.list</nowiki>
|-
| style="padding:8px 16px;font-size:16px;"|<nowiki>sudo apt update</nowiki> || style="padding:8px 16px;font-size: 16px;|<nowiki>sudo apt update</nowiki>
|}

===Add the Mono repository to Ubuntu, Debian, Fedora===

At time of writing, [https://www.mono-project.com/download/stable/#download-lin-ubuntu download-lin-ubuntu], shows the instructions for versions 16, 18, and 20 of Ubuntu.

Equally, [https://www.mono-project.com/download/stable/#download-lin-debian download-lin-debian], gives details for debian, and [https://www.mono-project.com/download/stable/#download-lin-fedora download-lin-fedora] for Fedora.

Others can be found by choosing other tabs on any of those links.

== Installing Mono instruction ==

Now we have the certificate needed, and the repository for mono-complete is added to our source list, we can do the actual install:
: <code>sudo apt install -y mono-complete</code>.

* The “sudo”, “apt”, “install”, and “-y” have [[#The various components to commands for installation|already been explained]].
* The "mono-complete" is the package we want.

:Please note that if you just specify “mono”, you will get ‘’’mono-devel’’’ (the developer edition) that does not include all the components required by each of the Cumulus executables.

Please note that a particular MX build might specify it needs a particular version of Mono. Hence, although normally you can upgrade any (CumulusMX.exe, ExportToMySQL.exe, CreateMissing.exe, proposed CreateRecords) cumulus package without upgrading Mono, sometimes you will need to upgrade Mono, and that means following above install instructions again.

The latest release of Mono, for a variety of Linux distributions, can always be downloaded from [https://www.mono-project.com/download/stable/#download-lin]:
# follow step 1 there,
# but in step 2 replace ‘’’mono-devel‘’’ by ‘’’mono-complete’’’

The complete mono package includes a component (mono-xsp4) that creates a simple web server to run ASP.NET 4.0 applications. MX does not need this, so type <code>sudo update-rc.d mono-xsp4 disable</code>, to stop it being used (without needing to do a <code>sudo apt remove</code> followed by the name of component you no longer want).

=Cumulus packages=


(At time of writing this "CreateRecords.exe" is proposed, and under development, but not released).
Welcome back anybody who has skipped the technical sections above, everybody needs to read this section.


Note use of plural in section name above, the following sub-sections will install various packages produced by developer Mark Crossley. If you are using the [[Software#Cumulus_MX|pre-built disc image]], then (unless the MX release version included in your image is an old one) you should skip the instructions for installing "CumulusMX" itself.


==Handling zip files==
==Handling zip files==
Line 305: Line 106:
Be aware, you may need to adjust the settings within that application for how it handles the file structure. The preferences may determine whether the unzip process preserves the file structure used when the zip was created (i.e. each file remains in any sub-folder) or it ignores the folder structure. For the Cumulus context, it is essential to preserve the folder structure. You may also be asked where you want the files to be extracted to, or the default settings might always use a particular destination (and that might be a '''tmp''' folder).
Be aware, you may need to adjust the settings within that application for how it handles the file structure. The preferences may determine whether the unzip process preserves the file structure used when the zip was created (i.e. each file remains in any sub-folder) or it ignores the folder structure. For the Cumulus context, it is essential to preserve the folder structure. You may also be asked where you want the files to be extracted to, or the default settings might always use a particular destination (and that might be a '''tmp''' folder).


For example on the Raspberry Pi operating system, there is a package called '''xarchiver''', in its Graphical User Interface (GUI), there is a menu called "Action", and the final option in that menu is "Preferences". There, in "Archive" section, you can select "zip" as the preferred archive format (using a dropdown) and whether you want the application to confirm with you before deleting any files; in "Advanced" section, you can select the directory to use for the extraction. If you are using the lite version of the RPi OS, then you need to edit the '''/home/pi/.config/xarchiver/xarchiverrc''' file to set preferences, before you use the archiver package. Once you have started the archiver package, and told it which file to process, you can click on '''Extract files''',
For example on the Raspberry Pi operating system, there is a package called '''xarchiver''', in its Graphical User Interface (GUI), there is a menu called "Action", and the final option in that menu is "Preferences". There, in "Archive" section, you can select "zip" as the preferred archive format (using a drop-down) and whether you want the application to confirm with you before deleting any files; in "Advanced" section, you can select the directory to use for the extraction. If you are using the lite version of the RPi OS, then you need to edit the '''/home/pi/.config/xarchiver/xarchiverrc''' file to set preferences, before you use the archiver package. Once you have started the archiver package, and told it which file to process, you can click on '''Extract files''',
the GUI presents a screen of options:
the GUI presents a screen of options:
* "Extract to:", use the icon to browse to the required location if it has not been set up in preferences
* "Extract to:", use the icon to browse to the required location if it has not been set up in preferences
* "Ensure a containg directory", tick this if it has not been set in the configuration file
* "Ensure a containing directory", tick this if it has not been set in the configuration file
* "Files", select "All files", the advice is to overwrite all of any existing files if you are upgrading, but you definitely need all files if this is a new install
* "Files", select "All files", the advice is to overwrite all of any existing files if you are upgrading, but you definitely need all files if this is a new install
* "Options"
* "Options"
Line 325: Line 126:


It is important to minimise the length of the path name, because this path name has to be passed between various different software languages (and longer paths risk truncation).
It is important to minimise the length of the path name, because this path name has to be passed between various different software languages (and longer paths risk truncation).

===MX can severely damage storage===

MX now assumes by default that you are going to use its [[New Default Web Site Information|Default Web Site]]. That means that by default MX will re-generate temporary files in its [[Web folder|/web sub-folder]] on a frequent time-scale. That number of files writes will considerably shorten the working life-time of the "high capacity micro-SD" card that is the default storage for the Raspberry Pi. It will also considerably shorten the life of any flash memory (e.g. memory card) or external drive (with a spining disc and moving head) that you might install MX on.

The expected life of any storage device, and the extent to which its life is shortened depends on the actual device. The external devices that have the longest life (and therefore can cope most easily with multiple read/write actions) are solid state discs (SSD).

All Linux computers will have some random access memory chips (RAM) and it is worthwhile to define part of that RAM as a drive used for temporary files. For a Raspberry Pi computer, a typical approach would be to edit the fstab file, adding the line ''tmpfs /var/tmp tmpfs nodev,nosuid,size=1M 0 0'', but the size you choose will depend on RAM available and what temporary files are being created. For maximum life of the "high capacity micro-SD" card if that is what your computer boots from, you should create a symbolic link path that maps the '''/tmp''' folder used by the system to your '''/var/tmp''' you have just defined in RAM. The difficulty will be that you cannot create a logical redirect on '''/tmp''' if the folder is already in use, so that makes it too complicated to explain here.




Line 352: Line 145:
# '''CumulusMX''':
# '''CumulusMX''':
#* '''CumulusMX.exe''' is written in C#, that has been developed by Mark Crossley, but still contains some code by Steve Loft
#* '''CumulusMX.exe''' is written in C#, that has been developed by Mark Crossley, but still contains some code by Steve Loft
#* Download '''CumulusMX zip file’’’ from the link at[[Software#Latest_build_distribution_download]]
#* Download '''CumulusMX zip file’’’ from the link at [[Software#Latest_build_distribution_download]]
# [[Software#Create_Missing|'''Create Missing''']]:
# [[Software#Create_Missing|'''Create Missing''']]:
#* '''CreateMissing.exe''' is also written in C#, created, and developed, by Mark Crossley
#* '''CreateMissing.exe''' is also written in C#, created, and developed, by Mark Crossley
Line 365: Line 158:
#* '''ExportToMySQL.exe''' is not (at the time this was written) documented in this Wiki although [[MX_Administrative_Interface#MySQL_settings]] does describe a similar utility (written by Steve Loft) that was actually included within early CumulusMX zip downloads.
#* '''ExportToMySQL.exe''' is not (at the time this was written) documented in this Wiki although [[MX_Administrative_Interface#MySQL_settings]] does describe a similar utility (written by Steve Loft) that was actually included within early CumulusMX zip downloads.


As at 9 March 2020, another utility, '''CreateRecord''', has been initialised in the Github areas managed by the developer where Cumulus is worked on, although it appears to be just a concept (any code on the developer's computer has not yet been included) on github. This will, if my understanding is correct, read [[dayfile.txt]] and use that to update the various [[:Category:Ini Files|extreme record files]].
As at 9 March 2020, another utility, '''CreateRecord''', has been initialised in the Github areas managed by the developer where Cumulus is worked on, although it appears to be just a concept on github. This will, if my understanding is correct, read [[dayfile.txt]] and use that to update the various [[:Category:Ini Files|extreme record files]]. The developer is still aiming to make this available, but his work on it (on his computer) has been stalled by the level of pressure being applied for bug-fixes and changes to MX itself.

===Alternative download link for older package releases===


Because the developer uses Git Hub to manage releases, the older releases remain available.
===Alternative download link for older MX releases===


====Old Cumulus MX packages====
Skip this sub-section if either you have installed the "pre-built disc image", or the current MX release is stable (it has been available for a while and nobody has reported any bugs).
Skip this subsection if either you have installed the "pre-built disc image", or the current MX release is stable (it has been available for a while and nobody has reported any bugs).


Check if posts in the [https://cumulus.hosiene.co.uk/viewforum.php?f=40 Cumulus Support Forum] tell you that the current release of MX has one or more bug(s) that affects one or more aspect(s) of MX that you intend to use.
Check if posts in the [https://cumulus.hosiene.co.uk/viewforum.php?f=40 Cumulus Support Forum] tell you that the current release of MX has one or more bug(s) that affects one or more aspect(s) of MX that you intend to use.
Line 378: Line 174:
* Plus a whole host of optional features, and different external upload sites, (typically each of these optional features are only used by a sub-set of Cumulus users).
* Plus a whole host of optional features, and different external upload sites, (typically each of these optional features are only used by a sub-set of Cumulus users).


Anyway, '''you can download any earlier build, without the bug''', from [https://github.com/cumulusmx/CumulusMX/releases CumulusMX/releases].
Anyway, '''you can download any earlier MX build, without the bug''', from [https://github.com/cumulusmx/CumulusMX/releases CumulusMX/releases].


====Old utilities====
You need to ensure that you use the right version of "CreateMissing.exe" and "ExportToMySQL.exe" utilities for the MX release you are running, so if you are using an old MX release, you will need to go directly to the [https://github.com/cumulusmx Cumulus MX github] page, and navigate to the utility of interest, to download an older version of these utilities that matches your older MX.


The zips for "CreateMissing.exe" and "ExportToMySQL.exe" utilities do NOT contain the '''''.dll''''' components that they need when they are running.
==Upgrading a Cumulus package==


This means that each version of "CreateMissing.exe" and "ExportToMySQL.exe" utilities is dependent on it being used with a release of Cumulus MX that does have correct '''''.dll''''' components in its release distribution.
Upgrading to a new MX release is explained [[Updating_MX_to_new_version|here]], but basically follow instructions above, and install over your existing files. The alternative is to install in a new folder (or rename the old one), and copy across files not in the release from old location to new location.


That in turn means you can't use the latest version of the utility with older MX releases, nor can you use an old utility version with latest MX release. This is why [[Software#By_Mark_Crossley|utilities downloads]] make clear which MX release is the minimum for them.
==Changing location of Cumulus==


The older versions of these "CreateMissing.exe" and "ExportToMySQL.exe" utilities are available by going directly to the [https://github.com/cumulusmx Cumulus MX github] page, and navigating to the utility of interest. However, to use those older versions, you also need to download the corresponding older MX release, because the MX distributions contain the .dll files that the utilities require, they are not in the utilities zip. Because of this complication, novice users are advised not to attempt to use the older utilities, even if the latest version appears to have a bug. Technical users may be able to work out which .dll files are needed and can be safely added back (if they are not left over from when that past MX release was in use). An alternative is to create a new folder with the old release packages (MX and the utility of interest), a copy of the latest Cumulus.ini file, and a copy of all files from /data sub-folder; then afterwards copy back the changed files into original /data folder.
If your install, or upgrade, is creating MX in a different place to where you previously ran Cumulus, then you will want to copy files across that are not in the zip extract distribution.


==Upgrading a Cumulus package==


Always check the release announcements in [https://cumulus.hosiene.co.uk/viewtopic.php?f=40&t=17887 Cumulus MX announcements] for any action needed in planned upgrade. In brief, all files from new release distribution replace the files from previous release, and the download/unzip is as covered above.
==Moving from Microsoft Windows to Linux==


No further action needed for upgrade of "Create Missing" or "Export To My SQL" or "Create Records". See below for upgrade of main Cumulus MX package.
Skip the following sub-sections if this is your first installation of MX, or if both the old location and the new location for MX are on Linux computers.


If you are running an older MX release, before skipping in-between versions please check [[Updating_MX_to_new_version|here]].
===Line terminators in .txt files===


If you run MX as a service, then:
If you are a novice to computers, skip this sub-section and the next, go directly to [[#File Names & Paths]].
# Ensure you are not doing any changes to settings
# Leave MX running as you copy files from the new release distribution over the existing files
# Try to pick a time just after MX has done any standard interval store of readings or upload, so that it is least busy
# Use <code>sudo systemctl restart cumulusmx</code> to stop and then restart MX picking up the new files
# Result, downtime of MX kept to a minimum, so avoiding losing data


If you run MX interactively, do the unzip into a temporary location before you stop MX, then copy all files from temporary location over your existing files, and finally restart MX. Depending on your weather station type, it might or might not offer historic data catch-up, so you might lose some data while MX is stopped, and therefore should keep the downtime to a minimum.
You need to have some technical understanding to do an action that might encounter the issues discussed here. For normal MX usage, line terminators do not matter.


The alternative is to install in a new folder (or rename the old one), and copy across files not in the release from old location to new location, but in that alternative you might forget some files.
If you are moving from Microsoft Windows to Mac OS, be aware that Microsoft ends each line with two characters (Carriage Return and Line Feed) while Unix/Linux ends each line with a single character (Carriage Return). Cumulus can cope with both approaches for existing files, but will create new files correctly for Mac OS.


==Changing location of Cumulus MX==
If you are moving from Microsoft Windows to Linux, be aware that Microsoft ends each line with two characters (Carriage Return and Line Feed) while Unix/Linux ends each line with a single character (Line Feed). Cumulus can cope with both approaches for existing files, but will create new files correctly for Linux.

If you run your Linux computer in a headless mode, accessing its files by a remote terminal session, be aware that the line terminator used by the remote computer may be applied to files affected by whatever command you do remotely. Equally, running a Cumulus executable (MX or one of the utilities) may create new files with the wrong end of line terminator. The latest releases of both "CumulusMX.exe" and "CreateMissing.exe" have been amended to create their new files with the same line terminators as are used by any existing files they read. Older releases adopted whatever line terminator was used by the device from which the executable run instruction was issued.

===Reading Cumulus files using your JavaScript, your PHP scripts, and packages from third-parties===

If you have written a script to work for a Microsoft Windows device, it might need editing to still work in a Linux environment. If you use a third-party provided package on your Linux computer, you may need to check if the author has coded it assuming it will be run on Microsoft Windows.

It is not appropriate for this Wiki page to go into full technical detail, but here is a quick summary of how unexpected line terminators can stop scripts working:
* If the script expects the Linux LF, and finds CR LF, then the final field of each CSV line has an invalid character in it, so your script will not be able to understand that field as a numerical value (or time-stamp).
* If the script expects the Mac OS CR only, and finds CR LF, then after the first line, each subsequent line starts with a “LF”. Most scripts will be processing [[Daily Summary|dayfile.txt]], [[Standard log files|MMMyylog.txt]], or [[Extra Sensor Files]], all of which have date as first field, and the "LF" prefix stops that field being seen as a date. In the worse case scenario, it might mean the script sees empty lines between each valid line.
* If the script expects CR only, but just finds LF, the script will believe the whole file is just one line, and the fields before and after the LF will be treated as a single field (merging the last value of one line with the date that should be on next line) so your script will not be able to understand that field as a numerical value (or time-stamp).
* If the script was written for a Microsoft Windows environment, it will expect CR LF, but might be confused if the end of line is different

===Editing Cumulus files outside MX===

If you try to edit a file outside MX, the application you choose to use will normally adopt the line terminators used by the device on which you are using the application.

Any good quality editor should by default save the file with the same line terminator as it had before.

If you are using an editor designed for editing computer files, it should have an option to [[#Changing line terminators|choose which line terminator you need]].

===Changing line terminators===

Many editors designed for programmers (they might be described as providing a programming development environment) can change the line ending of every line (either while file is being edited or when file is saved).

‘’’Geany’’’ is a programming development editor available for Microsoft Windows, but included by default on some Linux systems including Raspberry Pi, that can do this ('''Document''' menu, -->> '''Select Line Endings''').

''Notepad++'' is another editor available for multiple operating systems ('''Edit''' menu -->> '''EOL conversion''').

Both have capabilities to make such changes on either the single file that has focus, or all loaded files.

There are many more editors designed for programmers, and you may use one that is not listed above, so you may need to search for the relevant option.


===File Names & Paths===

Another issue that may be encountered when moving from Windows to Linux is the difference in File Names & Paths.
All Unix file names are Case Sensitive, and the separator is "/".

Microsoft Windows Operating Sytem deliberately chose to be different and uses "\". That causes a problem because "\" is also used to denote a control character (e.g. '\t' is horizontal tab, '\n' is new line) and so Unix based computers will strip out any two character sequences they recognise as representing control characters from any file paths they read.

This could be applicable if you were using Extra Web files functionality in your old Cumulus installation on a Microsoft Windows computer. You need to go into the settings page for '''Extra web files''', and edit each local path for it to work on your Linux computer. If you have followed advice on [[Customised templates]] page, you will be using a location outside the MX file structure, so you knew you had to change local file paths anyway for your new MX installation.

Here is an example changing the case and the separators where the path is within the MX file structure: ''Web\extrapageT.htm'' in Windows, changed to read '''web/extrapageT.htm''' in Linux.

===data sub-folder===

In general, any file in the old [[Data folder|data sub-folder]] should be copied into the new location. This might be a straight "copy and paste", it might be a "file-transfer", or you might use a portable drive to carry the files from the old device to the your Linux computer's MX folder.

If your previous Cumulus installation was of the legacy software, version 1.9.4, or earlier, then you need to do a lot of reading:
** [[Amending dayfile]] tells you about how MX is far more fussy about the content in [[dayfile.txt]]
** [[:Category:Ini Files|.ini files]] explains how time-stamps are formatted differently in the extreme tracking files
** [[Migrating from Cumulus 1 to MX]] gives some advice about differences in settings, but be aware that the way MX handles settings varies by release, and information on the linked page may be out of date

A further complication is that the legacy Cumulus software would read any [[:Category:Files with Comma Separated Values]] found in the [[Data folder|data sub-folder]], but MX ignores any of those files with dates prior to the date specified in the [[Cumulus.ini#Data_Logging|'''StartDate=xxxxx''']] parameter, edit this date using ''Station Settings → Common Options → Advanced Options → Records Began date''. If you have set up MX at a different location to where it was before, then you may need to do the above edit, unless the new MX release is able to read the [[Cumulus.ini]] used in the old location - see [[#Configuration Files to copy across from any previous Cumulus installation]].

Complications occur if the locale used by '''Mono''' or the locale specified when starting MX using [[#-lang parameter for changing Locale|-lang parameter]] differs from the locale for your previous device (please see [[:Category:Files with Comma Separated Values]] because some locales separate fields with commas, some separate integer and decimal parts of real numbers with commas; not to mention all sorts of issues with how dates are formatted). At time of writing this, the main MX developer has proposed that the format of files with comma separated values will be fixed, so all dates will use one standard format, all numbers will use decimal points, and the field separating character will be fixed, but no public MX release has this restriction yet.

===web sub-folder===

If you are using the default web pages, you will need to create a lot of symbolic links here pointing to the temporary folder you set up in RAM if you read the technical information earlier.

The links you need depend on which options you select in settings, you might find it easier to wait until you have run MX for a while to see what files are created that end in ".json".

If MX is currently running, you need to stop it, or at least alter any options that generate .json files. Then you must delete those files that end in ".json", except that you don't delete "websitedataT.json".

In a terminal session, issue commands in the following format for each file (this example relates to Raspberry Pi and uses "/var/tmp" which was defined in the extra line added to fstab earlier):

<code>sudo ln -s /var/tmp/availabledata.json CHOSEN PATH/CumulusMX/web/availabledata.json</code>

Notes:
* The "-s" flag is what says you are creating a symbolic link
* Full paths are given both for the file that MX is to be redirected to, and after it the path where it expects to create the file
* "CHOSEN PATH" is defined in [[#Where to install all packages?]], but basically it starts with a "/" and defines the path to get to where "CumulusMX" is a sub-folder.
* The text "availabledata.json" is just one file in the set of files linked from [[:Category:JSON Files]].

===Report sub-folder===

By default MX now creates monthly and annual reports that are in the style used by NOAA in USA. If you have been using this functionality before (and it is optional) then you need to file transfer, or copy, all the files that were in the old [[Reports folder]] into the new folder of that name.

If your previous installation was not on Linux, see [[#Line terminators in .txt files]], because you might want to either regenerate all these files, or to open them all in an editor that can alter the line terminator.


If your install, or upgrade, is creating MX in a different place to where you previously ran Cumulus, then you will want to copy files across that are not in the zip extract distribution.


==Configuration Files to copy across from any previous Cumulus installation==
===Configuration Files to copy across from any previous Cumulus installation===


There are two configuration files that are not included in any MX release:
There are two configuration files that are not included in any MX release:
Line 537: Line 259:
If you previously used an older release of Cumulus, but in this new installation will be using the latest release (latest is what is normally best, unless it has bugs), you may want to read up on all the changes between your old release and the current release, not just changes that affect the configuration file.
If you previously used an older release of Cumulus, but in this new installation will be using the latest release (latest is what is normally best, unless it has bugs), you may want to read up on all the changes between your old release and the current release, not just changes that affect the configuration file.


If you have used Cumulus 1 before, and decide to start with a new "Cumulus.ini" file, then you will need to work through all settings, to ensure they are set as you want. Please remember that when you use MX for first time, it uses that date it was first run as a starting date, and ignores any data found with earlier dates. Therefore you must change that start date:
=Running MX=
'''MX interface''' --> Setting menu --> '''Station Settings''' --> Click on ''General Settings'' --> Click on '''Advanced Options''' --> Edit ''Records Began Date'' following instructions below that field


==="data" directory===
Please read the appropriate sub-sections within this section, because the advice depends on whether MX has been run before, and how you want to run it.


Please see [[:Category:Files_with_Comma_Separated_Values]], [[:Category:Ini_Files]], and [[Weather_Diary]], for information if you are moving from Cumulus 1 to MX. Otherwise just copy files from any existing folder to your new one.
==Your first run of MX on Linux==


You may also wish to read:
Once you have got all the files sorted out as described above, you need to run MX.
** [[Amending dayfile]] tells you about how MX is far more fussy about the content in [[dayfile.txt]]
** [[:Category:Ini Files|.ini files]] explains how time-stamps are formatted differently in the extreme tracking files
** [[Migrating from Cumulus 1 to MX]] gives some advice about differences in settings, but be aware that the way MX handles settings varies by release, and information on the linked page may be out of date


Complications occur if the locale used by '''Mono''' or the locale specified when starting MX using [[#-lang parameter for changing Locale|-lang parameter]] differs from the locale for your previous device (please see [[:Category:Files with Comma Separated Values]] because some locales separate fields with commas, some separate integer and decimal parts of real numbers with commas; not to mention all sorts of issues with how dates are formatted). The main MX developer proposed that the format of files with comma separated values will be fixed from a release planned for September 2020, so all dates will use one standard format, all numbers will use decimal points, and the field separating character will be fixed.
On the first run of MX, unless you have run a recent release before, you need to work through either the '''Config wizard''' or all the individual settings pages (or both) as accessed from "Settings" menu. It is suggested you run MX interactively (see below) to do this, as you will then need to close MX, and then start it up again.


Update May 2022, this has been put on hold, no public MX release has this restriction yet.
Information about settings is on other Wiki pages ([[MX Administrative Interface]] and [[Cumulus.ini]]), so not much needs to be said here, except that you won't be able to '''Update Alarms''' without having first enabled and defined "Email Server Settings" on the "Internet settings" page. The complication is that you need to go into the "Alarm Settings" page and use '''Update Alarms''' to set what is displayed on the "dashboard" page of the interface to what suits your weather staion type!


==Running MX interactively==


==="Reports" directory===
To run MX interactively, you must open a terminal window, and leave it open until after you have closed MX.


By default MX now creates monthly and annual reports that are in the style used by NOAA in USA. If you have been using this functionality before (and it is optional) then you need to file transfer, or copy, all the files that were in the old [[Reports folder]] into the new folder of that name. Do look at that cross-reference, and read about the encoding default differences between Cumulus 1 and MX.
The simplest instruction to run Cumulus MX is <code>cd CHOSEN PATH/CumulusMX && sudo mono CumulusMX.exe</code>.
* This is two commands issued together, the first changes the working folder, the second actually starts the main executable


=MX can cause problems with storage=
Before running MX, look up the section later that talks about optional parameters:
<code>sudo mono CumulusMX.exe [optional parameters]</code>


MX now assumes by default that you are going to use its [[New Default Web Site Information|Default Web Site]]. That means that by default MX will re-generate temporary files in its [[Web folder|/web sub-folder]] on a frequent time-scale. That number of files writes will considerably shorten the working life-time of the "high capacity micro-SD" card that is the default storage for the Raspberry Pi. It will also considerably shorten the life of any flash memory (e.g. memory card) that you might install MX on.
When you want MX to stop, you must (for Linux) within your terminal session hold down the "Ctrl" button on your keyboard, and press "C". After that you can choose to close the terminal window.


The expected life of any storage device, and the extent to which its life is shortened depends on the actual device. The external devices that have the longest life (and therefore can cope most easily with multiple read/write actions) are solid state discs (SSD). Also the larger the capacity of the storage device, the more places on the device where files can be stored and the storing algorithm will try to spread the storing evenly across the entire storage area, so wear at any one location is reduced.
Note that if you use a different computer to access the computer that MX runs on, what has been called "terminal window" above might be called a "Command window", a "Powershell window" or some other name. Using control sequeNextnces on a remote session may not always be straight forward. In theory, Cumulus MX will also close tidily if you close a remote terminal window, but this may not always be true.


All Linux computers will have some random access memory chips (RAM) and it is worthwhile to define part of that RAM as a drive used for temporary files. For a Raspberry Pi computer, a typical approach would be to edit the fstab file, adding the line ''tmpfs /run/tmp tmpfs nodev,nosuid,size=1M 0 0'', but the size you choose will depend on RAM available and what temporary files are being created. For maximum life of the "high capacity micro-SD" card if that is what your computer boots from, you should create a symbolic link path that maps the '''/tmp''' folder used by the system to your '''/run/tmp''' you have just defined in RAM. The difficulty will be that you cannot create a logical redirect on '''/tmp''' if the folder is already in use, so that makes it too complicated to explain here.


==web directory==
Use <code>'''ps -ef | grep -i cumulus | grep -v grep'''</code> to see if Cumulus is running or not.


All the files in this folder come from the download.
== Running another executable with a terminal session left open ==


However, when you are running MX, it may try to create temporary files here, and following the advice above, you may decide to set up symbolic links so any attempt to create a temporary file in the "web" folder is redirected to the temporary folder you set up in RAM.
Open a terminal window, then navigate to the folder where you have installed the 3 Cumulus executables:


The links you need depend on which options you select in settings, you might find it easier to wait until you have run MX for a while to see what files are created that end in ".json".
<code>cd CHOSEN PATH/CumulusMX</code>


If MX is currently running, you need to stop it, or at least alter any options that generate .json files. Then you must delete those files that end in ".json", except that you don't delete "websitedataT.json".
Next decide which executable you want to run, for [[Software#Create_Missing|Create Missing utility]], that link takes you to a section of this Wiki where there are links to more information about the utility, to run it type:


In a terminal session, issue commands in the following format for each file (this example relates to Raspberry Pi and uses "/var/tmp" which was defined in the extra line added to fstab earlier):
<code>sudo mono CreateMissing.exe</code>


<code>sudo ln -s /run/tmp/websitedata.json CHOSEN PATH/CumulusMX/web/websitedata.json</code>
To run [[Software#Export_To_MySQL|Export To My SQL]], you change the name of the executable above and add the necessary parameters, as explained in links from that link.


Notes:
If you have followed advice at [[#Where to install all packages?]], the user you are using will own the "CHOSEN PATH/CumulusMX" folder and you may be able to omit the "sudo".
* The "-s" flag is what says you are creating a symbolic link
* Full paths are given both for the file that MX is to be redirected to, and after it the path where it expects to create the file
* "CHOSEN PATH" is defined in [[#Where to install all packages?]], but basically it starts with a "/" and defines the path to get to where "CumulusMX" is a sub-folder.
* The text "websitedata.json" is just one file in the set of files linked from [[:Category:JSON Files]].


=Running MX=
Just in case it is not obvious .... if you start any executable using this command in a terminal window on your Pi, you must leave that session running, or that executable will stop running.


There are multiple subsections here, you are unlikely to need to read them all. Look at each, and decide if it applies to you.
You can start it off directly on your Pi, and then
*optionally disconnect the keyboard,
*switch off monitor or TV attached to your Pi,
*Just ensure you leave Pi on (with that window minimised) so that terminal session continues running.


== Parameters ==
==Running MX as a Linux "systemd" service==


CumulusMX.exe can take a number of optional parameters as summarised here:
It is advised that you run MX interactively to begin with, and only run it as a service when you are happy that all settings are correct, and that any uploading or other external tasks are working correctly.
{| class="wikitable" border="1"
!style="width:30px" | Parameter
!style="width:600px" | Description
|-
! scope="row" | -port nnnn
| This parameter can be used whether MX is running interactively or as a service. Used to change the port where the web server for the MX interface runs, when Cumulus starts, it will display the URL of the interface where you change the settings, this is port 8998 by default. To use it when running MX in interactive mode, type <code>sudo mono CumulusMX.exe -port 9999</code> and the interface will run at port 9999 instead.
|-
! scope="row" | -service
| This parameter is not available when running interactively. It is used in a service definition file, please see [[#Running MX as a Linux "systemd" service]] for all details
|-
! scope="row" | -lang {locale}
| This parameter can be used whether MX is running interactively or as a service. Used to change the locale that MX will use from the default on your computer. To use it when running MX in interactive mode, type <code>sudo mono CumulusMX.exe -lang en_GB</code. There is a list of locale codes at http://msdn.microsoft.com/en-gb/library/ee825488%28v=cs.20%29.aspx. Remember this changes whether MX uses decimal comma or decimal point (although the intention is that all Cumulus files will use decimal points, this will still affect the output from api calls, web tags, etc.) and how it names files that include letetrs representing a month abbreviation.
|-
! scope="row" | -debug
| This parameter can be used whether MX is running interactively or as a service. This is only available for [https://cumulus.hosiene.co.uk/viewtopic.php?p=138839#p138839 release 3.4.4 - Build 3068] onwards. This switches on debug and (from 3.1.0) data logging from the start-up of Cumulus MX. Please note this increases size of files created in [[MXdiags_folder]]. As an alternative to using this parameter, you can switch debug and data logging on and off within the MX interface settings, see the aforementioned link for instructions.
|-
! scope="row" | -wsport
| Applied to MX beta 3.0.0, no longer available, set the port for web sockets, now incorporated into the -port parameter.
|-
! scope="row" | -logging
| Applied to MX beta 3.0.0, no longer available, enabled just data logging, now incorporated into the -debug parameter
|}


Running interactively allows MX to display error messages to you, and to confirm when it is running normally. If you run MX as a service you do not get any direct feedback, and cannot see if there has been a problem or failure.


Cumulus MX constantly develops, information here may not keep up with changes made by developer.


==Your first run of MX on Linux==
If you are using a MX release before Patch release 3.8.4 - b3094 (14 September 2020), this "systemd" functionality was not available, and you should skip all the following sub-sections.


Once you have got all the files sorted out as described above, you need to run MX.


On the first run of MX, unless you have run a recent release before, you need to work through either the [[First_Run_of_MX|'''Config wizard''']] or all the individual settings pages (or both) as accessed from "Settings" menu. It is suggested you run MX interactively (see below) to do this, as you will then need to close MX, and then start it up again.
===Commands to start, stop, or restart (stop and start in one command) MX as a service===


Information about settings is on other Wiki pages ([[MX Administrative Interface]] and [[Cumulus.ini]]).
You will need to start (or restart) MX after you have defined (or redefined) the service as instructed in next sub-sections. The full set of commands to use with this service are at [[Raspberry_Pi_Image#systemctl_commands|systemctl_commands]], here I simply repeat the basic commands that can be used with any service (start, stop, and restart), just replace [service_name] with either '''cumulusmx''' or the name of another service.


== Run interactive or as a service==
* sudo systemctl start [service_name]
* sudo systemctl stop [service_name]
* sudo systemctl restart [service_name]


MX can be run in two different ways.
If you want MX to automatically start when your Linux computer is booted, just type <code>sudo systemctl enable cumulusmx</code> once, and it will be activated on each reboot. Change the "enable" into "disable" if you don't want an automatic restart, and change the name of the service to apply these commands to another service.


It is advised that you run MX interactively to begin with, and only run it as a service when you are happy that all settings are correct, and that any uploading or other external tasks are working correctly.
===Defining "cumulusmx" service for "systemd"===


Running interactively allows MX to display error messages to you, and to confirm when it is running normally. Just in case it is not obvious .... if you start any executable interactively in a terminal window on your Pi, you must leave that session running, or that executable will stop running
The MX release distribution you downloaded and unzipped earlier includes a file that can be used as a starting point for the service definition. Find this file at ''CHOSEN PATH/CumulusMX/MXutils/linux/cumulusmx.service''.


If you run MX as a service you do not get any direct feedback, and cannot see if there has been a problem or failure. Running as a "systemd" service was first made available at Patch release 3.8.4 - b3094 (14 September 2020).
For more information, see [https://cumulus.hosiene.co.uk/viewtopic.php?p=146473#p146473 original release announcement].


==Running MX interactively==
Please note the content of this file changes in some MX releases, the text here may not get updates each time there is such a change. The change at release 3.15.1 is described in [https://cumulus.hosiene.co.uk/viewtopic.php?p=162184#p162184 this forum post]. The text throughout this section has been updated to reflect that change.
====All users - mandatory edit of service file====


To run MX interactively, you must open a terminal window, and leave it open until after you have closed MX.
Please note the text shown here reflects content as at release 3.15.1. If you are using an earlier, or later, release then the supplied text might be different, but the mandatory edit described here is still needed.


The simplest instruction to run Cumulus MX is <code>cd CHOSEN PATH/CumulusMX && sudo mono CumulusMX.exe [optional parameters]</code>.
# Open the file at ''CHOSEN PATH/CumulusMX/MXutils/linux/cumulusmx.service'' using an editor. On a Raspberry Pi, use the file manager to navigate to this file, right click the file named, and select "Geany's Programmers Editor".
* This is two commands issued together, the first changes the working folder, the "&&" means that first command has to succeed before the second command is obeyed and actually starts the main executable
# Within the provided file you should find a [Service] section:
* This example has not included any optional parameters, as they are rarely needed, but the optional parameters available are as listed in table earlier.
<pre>[Service]
User=root
Group=root
ExecStart=/usr/bin/mono-service -d:/home/install/CumulusMX CumulusMX.exe -service
Type=forking
ExecStopPost=/bin/rm /tmp/CumulusMX.exe.lock</pre>


When you want MX to stop, you must (for Linux) within your terminal session hold down the "Ctrl" button on your keyboard, and press "c". A word of caution here, if you are accessing your Linux computer over a network from another computer, do be careful about using any control sequences, as it is possible that your "Ctrl" "C" sequence will be applied to an application other than Cumulus MX, if that terminal session has started more than one application. The issue is that all running applications use the same terminator, it should be applied to whatever is regarded as the "foreground" application at the moment the control key sequence is used, which is guaranteed to be MX if that terminal session has only been used for running MX, and MX has not launched any external applications. After that you can choose to close the terminal window.


===Interactive advice===
''Everyone must edit'' the line that begins with '''ExecStart=''':
# There is a mandatory edit of path name, and an option to add parameters to the MX execute instruction.
#* The '''mandatory''' change is to replace '''/home/install''' by what you have selected for CHOSEN PATH
#* An '''optional''' change is to add additional parameters after the '''-service''' (select from '''-debug''', -locale, -port) as described in sub-sections later, the example below assumes you want to add "-debug"
# The new line will then read something like '''ExecStart=/usr/bin/mono-service -d:CHOSEN PATH/CumulusMX CumulusMX.exe -service -debug'''


If you have followed advice at [[#Where to install all packages?]], the user you are using will own the "CHOSEN PATH/CumulusMX" folder and you ''may'' be able to omit the "sudo" befor the "mono". I say "may" because there are other reasons why you may need to run as root user, too technical to explain here.
If you are a technical user, you may want to read the next few sub-sections, before you save this file and finish the edit.


You can start it off directly on your Pi, and then
If you are a novice user, then you are advised to skip the technical sub-sections that follow, and proceed directly to numbered steps below that save the file and make it usable by "systemd".
*optionally disconnect the keyboard,
*switch off monitor or TV attached to your Pi,
*Just ensure you leave Pi on (with that window minimised) so that terminal session continues running.


===Running MX interactively from a remote computer===
If you are using a standard Raspberry Pi with some types of weather station, there is a technical change mentioned for editing the "[Unit]" section of the file while you are editing it, that can be implemented to ensure that Cumulus MX does a historic data catch up if that is possible.


This is similar to running a terminal session on the machine that you installed MX on. If your remote computer is running Microsoft Windows, then the option to run a terminal session, may be called "terminal", "powershell window", "command window", or you might install software such as "PuTTY" to provide the teminal (TTY is the abbreviation for "teletype", a device that was commonly used to access computers in the 1970s and early 1980s).
# Open the "File" menu, and select "Save as" and enter a new name '''cumulusmx_edited.service''' (using a new name stops it being overwritten when we upgrade MX)
# Exit out of the editor you are using
# Next, open a terminal session
# Now copy file to where it is needed to run the service <code>sudo cp EXISTING_PATH/CumulusMX/MXutils/linux/cumulusmx_edited.service /etc/systemd/system/cumulusmx.service</code>
# Now type <code>sudo systemctl daemon-reload</code>, this tells "sytemd" that it needs to reload all service definitions because either one has changed, or a new one has been added
# Finally, '''optionally''', create a symbolic link to that file using <code>sudo systemctl enable cumulusmx</code> if you want the service to automatically start after a reboot


These won't be explained any further here, but be aware that control key sequences may not work, and you may need to type "exit" to close the session.


Use <code>'''ps -ef | grep -i cumulus | grep -v grep'''</code> to see if Cumulus is running or not.
====Technical users - optional edits of service file====


== Running another executable with a terminal session left open ==
Novice users should read the guidance in previous sub-section.


Open a terminal window, then navigate to the folder where you have installed the 3 Cumulus executables:


To run "Create Missing utility" type <code>cd CHOSEN PATH/CumulusMX && sudo mono CreateMissing.exe</code>. It does not take any parameters, so that is all you need to know, although it is fully documented at [[Calculate_Missing_Values#CreateMissing.exe]] in this Wiki.
Three sub-sections follow, the first two cover edits to different sections of the file, everyone must read the third sub-section as that describes how to end edit, and what to do next.


To run [[Software#Export_To_MySQL|Export To My SQL]], you change the name of the executable above and add the necessary parameters, follow that link for more details.


If you already have the file open in an editor because of doing the edits in previous sub-section you are ready to skip to next sub-section.


==Running MX as a Linux "systemd" service==
Otherwise open the file at ''CHOSEN PATH/CumulusMX/MXutils/linux/cumulusmx.service'' using an editor. On a Raspberry Pi, use the file manager to navigate to this file, right click the file named, and select "Geany's Programmers Editor".


There is a one-off task to define a service file, after that you can simply issue commands to stop/start/restart the service.


For more information, see [https://cumulus.hosiene.co.uk/viewtopic.php?p=146473#p146473 original release announcement].
=====Technical users - optional pair of edits to "[Service]" section=====


===The Service definition file===
Novice readers are advised to let Cumulus MX use the root user, following the suggestion below to change user/group entries may cause all sorts of problems and needs a good level of technical understanding to follow through all implications.


The MX download includes a file that can be used as a starting point for the service definition. Find this file at ''CHOSEN PATH/CumulusMX/MXutils/linux/cumulusmx.service''. You do have to edit this file, and then you have to copy it to a new location, before you start the MX service for the first time.
As a side-note, some weather station types require MX to be run with '''root''' rights, this is why ''sudo'' is included in each example command, but if you have technical knowledge and know your weather station can be run with default user, you can omit the ''sudo'' shown in many commands, provided your user has ownership of all folders and files used by MX. The default service definition file assigns the ownership of all files that MX creates to the root user, this means you may not be able to edit Cumulus files outside MX because you are by default a user with restricted rights.


# Open the file at ''CHOSEN PATH/CumulusMX/MXutils/linux/cumulusmx.service'' using an editor (see [[Preparing_your_Linux_computer_for_MX#editing_files|editing_files]]).
# Within the provided file you should find a [Service] section (see the contents in previous sub-section)
#* On a Raspberry Pi with a graphical interface, use the file manager to navigate to this file, right click the file named, and select "Geany's Programmers Editor".
# Technical users might want to edit the '''User=root''' line so that the service will run as a different user, just change the name that appears after the "=" sign.
#* If you are accessing from another computer, using a terminal session, then "nano" is a suitable editor (explained at link just mentioned).
# Having changed the user name you may also need to edit the '''Group=root''' line to ensure the group name is valid for whatever new user you selected.
# Within the provided file you should find a [Service] section:
<pre>[Service]
User=root
Group=root
ExecStart=/usr/bin/mono-service -d:/home/install/CumulusMX CumulusMX.exe -service
Type=forking
ExecStopPost=/bin/rm -f /tmp/CumulusMX.exe.lock</pre>


*Be aware that what quoted above applies from MX 3.16.0 (b.3182, 30 Apr 2022) onwards, earlier releases did not include the "-f" flag in final line quoted above.


:There is more in the file, but for now focus on the line including "ExecStart=/usr/bin/mono-service -d:". Don't change any of the bit I just quoted.
=====Technical users - optional edit to "[Unit]" section=====


Almost certainly you will need to change "/home/install/CumulusMX" on that line. Replace that with "CHOSEN PATH/CumulusMX", i.e. the full path to the directory that the executables are being stored in.
The content of the "[Unit]" section of the service description file described here has evolved slightly as MX develops. The file was first added to the MX release package in Patch release 3.8.4 - b3094 (14 September 2020)
The only change is in references to '''network-online.target''':
* In that first version of the file <code>After=network-online.target</code> was the only mention.
Note: That means that '''after''' "systemd" has started the "cumulusmx" service, it can start the network service. (Note that the terminology ''after'' does not guarantee the network online detection service will be started.)
* From release 3.15.1 build 3170 (19 March 2022) a second mention was added, so the content became:
<pre>Wants=network-online.target
After=network-online.target</pre>
Note: The "wants" line tells "systemd" that the "cumulusmx" service wants the network online detection service to be started. (Note that the terminology ''wants'' means MX can still start even if the network service is not running, or if the attempt to start the network service fails).


The final line, with all possible parameters, could read: <code>'ExecStart=/usr/bin/mono-service -d:CHOSEN PATH/CumulusMX CumulusMX.exe -service -debug -port 999 - lang el-GR</code>
* Note the space between the path (just looked at) and the executable file,
* Note the mandatory parameter "-service" that follows a space after the "CumulusMX.exe", you must leave that untouched,
* Note you can remove/keep the rest of the line after the -service i.e. the other parameters (some with their values) -lang, -port, or -debug, (as defined in table earlier), are all optional.


'''Please follow these steps if you do need to make the suggested change here:'''
# Within the editor navigate to '''[Unit]''' section
# As mentioned above, the content of this section depends upon which MX release you are using.
# All release distributions that contain the file should have the following three lines:
## <code>[Unit]</code>
## <code>Description=CumulusMX service</code>
## <code>Documentation=https://cumuluswiki.org/a/Main_Page</code>
# Use the editor to create a blank line after <code>Documentation=https://cumuluswiki.org/a/Main_Page</code>
# Type into that blank line the following: <code>Requires= time-sync.target local-fs.target</code>
#* The terminology ''Requires'' tells "systemd" that the "cumulusmx" service should not be started until the services specified on that line have successfully started
#*# The '''local-fs.target''' specifies that the ''cumulusmx'' service requires the file service to have started, i.e. checks your computer can read files before it attempts to start the ''cumulusmx'' service
#*# The '''time-sync.target''' specifies that the ''cumulusmx'' service requires the computer to have synced with either a real-time clock chip, or a time found on the internet (NTP), i.e. this will ensure that Cumulus obtains the correct time from the computer to control all its actions
#*#* If you are using a weather station type that does not time-stamp the readings it supplies to a Raspberry Pi, adding that target reference is important
#*#* A standard RPi does not include a real time clock chip (it can be added via connections available), therefore when the RPi boots it initially uses a dummy clock, and this sets the time to when the RPi was last running.
#*#* That means without this target being included, a newly booted-up RPi will tell Cumulus MX the time is just after when the computer was shut down, that might be very different to the true current time. It means your Cumulus MX on restarting will skip the catch-up of historic data (should your weather station settings make that available). Some measurements will then get logged against the wrong time.
#*#* When the Raspberry Pi does do a time-sync, the time will suddenly jump, this is serious if this means the "rollover" time has been skipped over, as it implies the "dayfile.txt" will miss a line, and many measurements will be logged to wrong day.

=====Technical users - Saving the file and making it available to "systemd"=====


Technical user may do other edits on the file, these will be described later, for now save the changed file under a new name (so it won't be lost when you do a MX upgrade that replaces original file) within your MX installation:
# Open the "File" menu, and select "Save as" and enter a new name '''cumulusmx_edited.service''' (using a new name stops it being overwritten when we upgrade MX)
# Open the "File" menu, and select "Save as" and enter a new name '''cumulusmx_edited.service'''
# Exit out of the editor you are using
# Exit out of the editor you are using
# Next, open a terminal session
# Next, open a terminal session
# Now copy file to where it is needed to run the service <code>sudo cp EXISTING_PATH/CumulusMX/MXutils/linux/cumulusmx_edited.service /etc/systemd/system/cumulusmx.service</code>
# Now copy file to where it is needed to run the service <code>sudo cp EXISTING_PATH/CumulusMX/MXutils/linux/cumulusmx_edited.service /etc/systemd/system/cumulusmx.service</code>
# Now type <code>sudo systemctl daemon-reload</code>, this tells "sytemd" that it needs to reload all service definitions because either one has changed, or a new one has been added
# Now type <code>sudo systemctl daemon-reload</code>, this tells "systemd" that it needs to reload all service definitions because either one has changed, or a new one has been added
# Finally, '''optionally''', create a symbolic link to that file using <code>sudo systemctl enable cumulusmx</code> if you want the service to automatically start after a reboot
# Finally, '''optionally''', create a symbolic link to that file using <code>sudo systemctl enable cumulusmx</code> if you want the service to automatically start after a reboot


== Optional parameters to add to the instruction to run the MX engine ==


====Technical users - additional edits====
This list of parameters covers every parameter, if you are using the latest release skip the historic 3.0.0 sub-sections.


Novice users, skip this subsection. ''The changes in this subsection have to be made with other changes that are not covered here'' (they depend on your weather station type, and your computer type, so are not appropriate to a Wiki page trying to generalise, and anyway your contributor is not a technical expert).
Note that you ''may'' need to supply your root password after typing any 'sudo ...' command line if the instruction changes something set by another package (e.g. changing the locale for MX from the locale set by mono). The system will prompt you for this if it is needed.


:Look at the '''[Service]''' part of the file quoted above.
=== -port parameter for changing Port ===


This states Cumulus should use root for both the user it runs under and for the group permissions it uses. ''If you have the technical expertise'', you might choose to run MX in a different user, if your weather station type allows MX to run in a different user. If so, replace the "root" in its two locations. (Please note some weather stations require other changes outside this file before Cumulus can make contact, one example is discussed [https://cumulus.hosiene.co.uk/viewtopic.php?t=20413 on support forum here], but there are other topics that may be relevant).
When Cumulus starts, it will display the URL of the interface where you change the settings. he web server that MX initiates runs on port 8998 by default; if this is not suitable for some reason you can change it using the '-port' parameter on the command line if running interactively, or within the service definition file (see [[#All users - mandatory edit of service file]] if running as a service.


You may also wish to add an extra line after the "Group" line <code>ExecStartPre=/bin/sleep 5</code>, this [https://cumulus.hosiene.co.uk/viewtopic.php?p=163754#p163754 is to delay the starting of MX by 5 seconds while other services start] (on a reboot of your computer) that might affect MX. (For some users, change 5 into 10, it all depends what else is being started).
e.g. to use port 9999 instead:
<pre>sudo mono CumulusMX.exe -port 9999</pre>


:Look at the rest of the file, the '''[Unit]''' part.
=== The -service parameter===


For releases 3.8.4 to 3.15.0: you will see one reference to '''network-online.target''' in <code>After=network-online.target</code>.
You don't use this parameter in a terminal or interactive instruction for running MX. Instead it appears within a file that we use to set up for running MX as a service.


For release 3.15.1 build 3170 (19 March 2022) onwards: you will see an extra line <code>Wants=network-online.target</code>
See [[#Defining "cumulusmx" service for "systemd"]] and [[#All users - mandatory edit of service file]] for where "CumulusMX.exe -service" is used.


If you are a technical user, you might decide to edit the [Unit] part of the file, you have to decide what is needed in your context, only you know what other services are started by systemd on your computer, you can list all items using something like <code>systemctl list-unit-files</code> to see the services, but you still need to understand what each does.
=== -lang parameter for changing Locale ===


If your computer has online access, then it can look up the correct time online and adjust its clock. However, it might not even try to do that for say 10 minutes after being booted, and so there may be a benefit in making MX wait until after systemd has asked for the time to be synced, and asked that the local file-system is made ready so MX can read/update/store files. To achieve this, you might choose to add a blank line after '''<nowiki>Documentation=https://cumuluswiki.org/a/Main_Page</nowiki>''' and in that blank line, type <code>Requires= time-sync.target local-fs.target</code>. Using "Requires" ensures these requesting events have happened before MX can start, if they fail, MX will not be started, this example has not specified a time that MX should wait for the other services to start!
Individual computers may have different default for their locale. The forum reported an issue with OS X with its default US locale even if that is not your locale.


For that ''time-sync.target'' to work, you need to '''enable''', by creating the symbolic links needed, the appropriate services outside this edit:
As MX starts its output (to diagnostic log and to any interactive terminal window) says which locale is being used, '''Current culture: English (United States)'''. That default locale will relate to the one your computer had when mono is installed, as it is mono that tells MX all the locale settings. If you notice MX starting with wrong locale, issue the correct instruction to close MX.
<pre>sudo systemctl enable --now systemd-timesyncd.service
sudo systemctl enable --now systemd-time-wait-sync.service
</pre>


You can use a '''-lang''' parameter to change the locale as you restart MX. This parameter can be added to the service definition file (see [[#All users - mandatory edit of service file]], or it can be used in your command to start MX interactively. For example, in the UK, type:


Here is a quick explanation of all entries in this UNIT section:
:<code>sudo mono CumulusMX.exe -lang en-GB</code>
# Entries

#* The terminology "After" tells "systemd" that what is named can be started after MX, in this case it does not guarantee that the network service (to send data to a remote web server) will be started
Other locale examples: '''CumulusMX.exe -lang de-DE''', '''CumulusMX.exe -lang el-GR''' (this is one of the locales that reads numbers with '''integer,decimal''' format), '''CumulusMX.exe -lang nl-NL'''.
#* The terminology "Wants" tells "systemd" that what is named is wanted now, i.e. try to start before MX, but still start MX even if the starting of the network service fails.

#* The terminology ''Requires'' tells "systemd" that the "cumulusmx" service should not be started until the services specified on that line have successfully started
If you are not sure what value you need to supply for the -lang parameter, there is a list here - http://msdn.microsoft.com/en-gb/library/ee825488%28v=cs.20%29.aspx. You need to supply the code in the first column ("Language Culture Name") in that list.
#*# The '''local-fs.target''' specifies that the ''cumulusmx'' service requires the file service to have started, i.e. checks your computer can read files before it attempts to start the ''cumulusmx'' service

#*# The '''time-sync.target''' specifies that the ''cumulusmx'' service requires the computer to have synced with some time source (see notes below), which could be useful if your weather station type does not time-stamp readings stored in the console, and you want to ensure MX reads correct time from your computer
Note that this does not affect the language used by Cumulus MX (although it may in the future), it currently affects the decimal separator and the list separator. Also note that the developer has announced that in a future release of MX, all [[:Category:Files with Comma Separated Values|Files with Comma Separated Values]] will have a fixed format, i.e. it will no longer be possible to use a decimal comma within Cumulus files, and various other fields (like dates) will always have the same format. At the time this was written, there is no date set for this change.



=== -debug parameter for adding debugging ===

This is only available for [https://cumulus.hosiene.co.uk/viewtopic.php?p=138839#p138839 release 3.4.4 - Build 3068] onwards. This switches on debug and data logging from the start-up of Cumulus MX by adding a parameter within the service definition file (see [[#All users - mandatory edit of service file]] if running as a service.

If running MX interactively, then add as a parameter on the command line:
:<code>sudo mono CumulusMX.exe -debug</code>

MX has a default level of logging that stores in the [[MXdiags_folder]] folder a log file that shows some of the interaction with the weather station and some of the output actions done as MX runs. A new log is started each time MX is restarted.

If there is a problem, then there is a great benefit in actually increasing the level of detail in these logs; and that is done either within the settings (on recent MX releases this is on '''Program Settings''' page of admin interface - please see [[:Category:Diagnostics]] page for details) or by using the "-debug" parameter as explained above.

=== Parameters only applicable to Version 3.0.0 Beta builds of MX ===

The following two parameters cannot be used with MX since it came out of 3.0.0 beta.

==== -wsport parameter for web sockets ====

Beta builds in MX version 3.0.0 had an optional parameter <code>sudo mono CHOSEN PATH/CumulusMX/CumulusMX.exe -wsport nnnn</code> that determined which port (represented by a 4 digit number ''nnnn'') was used for '''Web Sockets'''.

Note use of this parameter is now deprecated, as it has been incorporated into '''-port''' parameter described earlier. The reason is that [https://cumulus.hosiene.co.uk/viewtopic.php?f=40&t=17887&p=138815&hilit=sockets#p138815 Web Sockets in all builds since 3045] use the same port for web sockets as for the HTTP port of the [[MX_Administrative_Interface#The_API_interface|Admin Interface]].

==== -logging parameter for debugging of data flow between station and MX====

Beta builds in MX version 3.0.0 had an optional parameter <code>sudo mono CumulusMX.exe -Logging=1</code> (for the station to MX transfers to have increased debugging logging).

Note use of this parameter is now deprecated, as it has been incorporated into '''-debug''', see above.


= Operating a web site with uploads from MX engine =

== The standard web pages ==

=== From release 3.10.1 ===

The web pages are a one-off upload from '''CumulusMX/webfiles'''. The data to be shown on these web pages are uploaded from [[:Category:JSON_Files|.json]] files in the [[web_folder]].

Please read [[New_Default_Web_Site_Information|this page]] for more information about styling options and other details.

=== Until release 3.9.7 ===

The styling and library files were a one-off upload from '''CumulusMX/webfiles'''. These release use [[Cumulus_template_file|template files]], these are [[Customised_templates#What_is_meant_by_.27Cumulus_processes_templates.27|processed by MX to add the variable data]], and this will create web pages that are uploaded to your web site.

Please read [[Customised_templates]] for further information about the various pages originally provided, and how you could customise them to suit you.
=== Comparison with legacy Cumulus 1 web pages ===

* Note that any web files, designed for Cumulus 1, cannot be used with MX, for multiple reasons
** so if moving from Cumulus 1 to MX, delete all your Cumulus 1 files from the "web" and "webfiles" sub-folders, and all files from your web server; then upload files from the new "webfiles" folder.
* The standard gauges are rather like the stand alone [[SteelSeries Gauges|SteelSeries gauges]] you could optionally add to Cumulus 1, but the MX ones are different.
** The new default gauges page does not display a graph when you hover over a gauge (Cumulus 1 generated some images that the stand alone Steel Series gauges page could use)
* The various charts pages for MX rely on MX to generate files with time and value pairs, these are stored in json format, the various web pages use a library package (Highstocks) to draw graphs from those data pairs.
** (The Trends page provided as standard in Cumulus 1 simply displayed images of graphs uploaded to the web server)

== Alternative ways to obtain web pages ==

You can choose to use some of the alternative web pages available from third parties and described [[:Category:User Contributions|on User Contributions page]].

== Using your own web pages ==

* Of course you can use your own web pages, instead of the standard ones. Assuming they need to include figures that are available as web tags, there are three alternative ways to implement this:
*# MX can process template files with a HTML structure and those web tags in the structure where values are required just as it does with the standard templates, and MX can upload the resulting web pages at either the real-time interval, the standard interval, or after end of day. All of this is covered on the [[Customised_templates|Customised templates]] page in this Wiki.
*# MX can process a file with a string of web tags mirroring the realtime.txt option in MX, and upload the resulting file so your web pages can use JavaScript for a one-off insert of the values or an Ajax routine to update the web page at a fixed interval.
*# Alternatively, you can use template scripts processed locally by MX that don't create web pages, but are uploaded by MX at either the real-time interval, the standard interval, or after end of day. These scripts simply initialise script variables with values obtained from web tags. You then independently have a set of web pages resident only on your web server (they don't exist where you run MX) using a combination of HTML and script content that bring in the script(s) with the variables by the appropriate syntax. All of this is covered on the [[Php_webtags|PHP web tags]] page in this wiki. As it suggests there, you might therefore have several files processed by Cumulus MX at these different intervals, converting the web tags into script variables, and then use AJAX (JavaScript that may use json format to bring in the variables) or PHP (using <tt>'require_once 'filename';</tt> syntax) to put those variables into a web page.

You may find [[PHP|this wiki page]] useful for understanding more about the different script languages.

=That is enough folks=

If you have read up to here, you now know the basics for using MX on Linux.

The remaining sections are more technical and so you can skip them.

=Technical Extra=

PLEASE SKIP ALL SUBSEQUENT SUB-SECTIONS IF YOU WANT TO AVOID TECHNICAL EXPLANATIONS.

== A very quick introduction to Linux ==

This article is not the place to teach you Linux, you can find books and on-line articles for yourself, but I list here enough for you to understand the instructions used elsewhere in this article.

If you have a Raspberry Pi with a monitor attached, you will see a raspberry icon that you can click to get Graphical User Interface access to many features, including shutdown options.

=== su and sudo ===

There is a command <code>su</code> that allows a terminal session to become a super user session with root privileges. If you use that command, without a '''sudo''' command in front, you need to type in the password (we changed earlier) when prompted. if you type <code>sudo su</code>, then you get root privileges without being asked to quote password. All subsequent lines in this terminal session will have a prompt that reminds you that you have root access and do not need to prefix subsequent commands with "sudo".

Normally, all terminal sessions will use the default "pi" user, and for individual commands, you will use a "sudo" prefix each time that command needs administrative rights, as this allows a standard Pi user to do tasks that otherwise only work for the root user.

You might use a "sudo" prefix if you need to access a part of the file structure that your user does not have any access to, or where the standard user does not have write (or execute) access.

There are also some commands (like displaying mounted storage) that are not available to a standard user. Here are 3 system commands that in terminal mode will only ever work with this prefix (although if you have installed the version of the Raspberry Pi Operating System that supports a graphical user interface you can also select these actions from a menu):
*'''sudo halt''' = stops any cpu functions, but leaves Pi running; used when you have reached the end of commands you want to do for now
*'''sudo poweroff''' = makes pi do a tidy shutdown and turn off its power; used when you will not be using your Pi for a while
*'''sudo reboot''' (or "sudo reboot -verbose" for diagnostic output during shutdown and reboot) = makes your Pi close down and then reboot; used when you change settings, and after you install new software, to ensure Pi starts with all applications running using the latest settings and latest already installed software

=== ~ and / ===

The tilde symbol '''~''' denotes the home directory for the current user. Sub-directories within the current user's folder can be identified by '''~/documents''' or similar notation.

To reference a folder in root or any other area, the prefix is always '''/'''.

If you are using the RPi OS GUI, it provides a file manager that displays folders and files, and if you have a mouse you can click on an object to see what actions are available. The file manager has "Home" and "Root" as bookmarks by default, you can bookmark others. Typically, any new partitions created can also be accessed from bookmarks. Depending on options you select, there may be icons on the GUI desktop to link to particular folders and clicking on these offers various options including opening them in file manager.

In a terminal environment, to see what files and folders are in the current directory, type <code>dir</code> for just names or <code>ls</code> for details.



=== folder commands ===

To make a new folder in the current directory, type <code>sudo mkdir folder_name</code>.

To remove a folder, that has no files in it, type in a particular path, type <code>sudo rmdir /path/directory</code>.

To remove a folder that does have files, and/or sub-folders within it, type tt>sudo rm -r /path/directory</code>, but remember the contents are gone for ever, so be absolutely sure you have specified the right folder!

To copy folders/files from one directory to another use something like <code>cp -R --update --preserve /home/pi/CumulusMX/backup/daily /media/pi/data/CumulusMX/archive</code>

Sometimes, you have a folder or file in just one place in the file system, but want to be able to access it at a different place (because something expects it in the second place), the syntax is <code>ln -s /path/elsewhere path/pointer_location</code>.

An example might be '''ln -s /var/lib/phpliteadmin/diary.db ~/CumulusMX/data/diary.db''' (phplite admin can only update databases in one folder /var/lib/phpliteadmin, or in older releases in /usr/share/phpliteadmin; while MX expects the file to be in its data folder but is happy with a logical pointer to another folder).

=== chmod ===

When you are attempting any of the actions listed in this article that involve reading, creating, editing, exeduting, or moving, files; you might see an error message generally because of a lack of write (or execute) permissions on an existing file or folder. Whilst <code>rm filename</code> will remove a file even if it is write protected, for nano you need to change the file permissions with <code>sudo chmod -R ugo+rw ~/CumulusMX</code> for modify access to all files in your Cumulus installation (see the syntax below if you want to restrict access).


*'''chmod''' command to modify permissions
* the '''-R''' indicates recursive action (i.e. including not just the named folder, but all files within it and all sub-folders, and all files within sub-folders)
*letters indicating whose permission is being modified
** '''u''' = Owning user (sometimes the owner is the user root, sometimes the owner is the user Pi, for our web pages later we change ownership)
** '''g''' = Group (by default the owning user is also a group, but a group can be defined if you want to give multiple users (with different passwords) the same rights of access)
** '''o''' = Other users (write permission here is needed if for example you are using FTP to move a file from a PC to your Pi, or vice versa)
* sign for add or remove permissions
* '''+''' = add permission
* '''-''' = remove permission
*letters indicating what permission is being changed
** '''r''' = read [4]
** '''w''' = write [2]
** '''x''' = execute [1]

Note that as an alternative shorter syntax you can use numbers e.g. '''666''' is equivalent to '''ugo+rw'''. The first digit in the number relates to ''u'', the second to ''g'' and the last to ''o''. The values in [] brackets in list of permissions above are added to derive each digit. So if you are reading the Cumulus support forum and you see a reference to permissions which includes a string of 3 digits, now you can understand what is meant.

=== editing files ===

*Do remember that file names are case sensitive.
*If you use the wrong case in a path/file name, it will be treated as a different "new" file.
*If a file editor does not display content you were expecting, look in case "new file" message appears because you have made a typo in the path/file name.

There are various text editors available on a Pi,
*if you have a mouse and click on a file, you should see "text editor" listed, that loads '''Mousepad''' which has a menubar at the top of its "Windows" like interface.
*in terminal mode '''nano''' is a text editor that by default lists the actions available making it easier for a novice to use.
*in both the GUI and terminal mode, Geary is a programmer's editor with lots of useful funtionality

All editors can create a file when a file does not exist and edit (subject to file permissions) an existing file. Use prefix of 'sudo' to give you access to any file irrespective of ownership, '''sudo''' does not change the actual file permissions, so you might find you can read a file, but not save it after you have done your edit.

====nano====

The full syntax is <code>sudo nano -B Path_file_name</code> where the '''-B''' means it will create a backup of how the file was before (this can be enabled while in the editor by pressing the control key down and typing B). Alternatively use '''-C''' which stores each version in a back-up directory. If you want to edit from a particular line and column you can use '''+line.column''', and also optionally use '''-l''' (lower-case "L") to display line numbers which might be useful when trying to correct a problem with a log file like [[dayfile.txt]]. If you don't specify a file name, then nano will create a new file and you will need to specify where to save it before exit.

After typing the nano command you need to specify a filename (it might include a path, see earlier sub-section for use of '''/''' and '''~''') and there are examples later in this article, but if you decide to ''host a web site on your Pi'' then you might want to edit its home page with (.html or .php) name like <code>sudo nano /var/www/html/index.php</code>.

After you have made an alteration to the current contents of the file, various options are shown at the bottom. Here are two key ones:
*First is '''^O''' which is used to save the file whilst staying in the editor, to do this press the control key down and type O. Next it shows the current file name, if you press '''Enter''' then that file will be overwritten.
**it allows you to type over the file name shown. If you choose to save as another file, you will be asked if the new name is correct (type '''Y''' to continue saving).
*Another is '''^X''' which means if you press the control key down and type X you get the exit dialogue. If you have not made any edits, or have already saved the file, this just exits the editor. If you have not used control and O to save the file, it asks whether you want to save the edited file (type '''Y'''), typing just the Y key lets save continue (any other key stroke exits without saving), then it shows the current file name, if you press '''Enter''' then that file will be overwritten.

You might find it useful to type <code>sudo nano /etc/nanorc</code> as this puts you into the configuration file for nano where you can set back-up, line-numbering, and other options.

====Geany====

This uses a GUI, you can set preferences and do all other actions using either menu selections (use mouse or keyboard) or control sequences (on keyboard). Once it knows what type of programming language, it can colour up the code; it can show you how many times variable identifiers are used; it can match opening and closing quotes, tags, and brackets; and it can ensure encoding and line terminators are correct.

Line-numbering is an option, so it can be used to edit MX log files, and (as BOM is an encoding option) you can be sure it won't add unwanted encoding.

== removing an unwanted file ==

You can remove a file with various commands, including <code>sudo rm filename</code>.


=== external storage ===

Generally, if you attach USB storage (a disc or a stick), Linux OS distributions will detect any existing partitions (yes a technical term) and allow you to read files stored in them. This applies whether the partition is formatted for Linux or for Microsoft Windows.

However, you may have a brand new, unformatted, drive, or you may want to delete, or add partitions, or to format them as Linux partitions (as these make the input/output significantly more efficient).

You can install software that uses a GUI to make this easy, e.g. '''gparted''' [https://gparted.org/ partition editor].


Alternatively, you can use a terminal session, and lots of commands:
#connect your external storage
#type '''su''' to gain administrative access
#enter your RPi password
#type '''fdisk -l''' (this is only available to root user) to see names for all storage your Linux computer can see
#an external drive will be named something like ''/dev/sd''''a''''' although that "a" might be "b" or a subsequent letter in alphabet depending on what has already been assigned
# if "sda" and "sdb" appear, or any others up to "sdz", the last one will relate to the most recently connected storage
#if your drive has partitions, then you will see further entries like '''/dev/sda1''' and ''/dev/sda2''.
#type '''df''' to see whether your drive is currently mounted (being used by computer system)
#if it is mounted, the command to use next is (type this accurately, there is a temptation to type an English word that adds an extra "n"!) <code>umount /dev/sda</code>, obviously replace the "a" by the appropriate letter seen in the earlier command
#if the drive does not have a partition, create one using <code>fdisk /dev/sda</code>, again changing the "a" into whatever letter was seen in response to the first "fdisk" command
#*"fdisk" is a utility, it will wait for further instructions, follow each with pressing "Enter"
#*type '''n''' as instruction to create a new partition
#*type '''p''' to make this the primary partition on this drive
#* type '''1''' to make this the first partition
#*accept default offered for first cylinder
#*accept default offered for last cylinder, if this is only partition, as that ensures the whole disk (apart from partition table) is available for your data
#*for simplicity, this guidance will not cover the possibility of multiple partitions
#*type '''t''' to say you are specifying the way you want this partition to be specified in partition table
#*optionally type '''L''' to see what file system types are available for the partition table
#*to select a "Linux" partition, type '''83'''
#*type '''w''' to create the partition you have now specified for Linux.
#Now we have a partition table and a partition on our drive, we can repeat '''fdisk -l''' to see the entry now added, it might be '''/dev/sda1''', where again the "a" might be a different letter
#To format this partition for Linux, we specify "ext4" as the way to format it using <code>mkfs.ext4 /dev/sda1</code>, again replacing the "a" as required.
#we need to create a folder within
#*"/media" for Linux in general
#*"/media/pi" for Raspberry PI OS
# As we will learn later, the relevant command (in RPi OS) is '''mkdir /media/pi/my_short_name''', where "my_short_name" is selected by you
#To mount our partition, we type <code>mount /dev/sda1 /media/pi/my_short_name</code>, where "sda1" is replaced by "sdb1" or whatever we saw in '''fdisk -l''', and "pi/my_short_name" is replaced by whatever we used in our make directory command.
#To (optionally) get our partition mounted at boot, we can use an editor (see later) to change the boot instructions, by typing <code>nano /etx/fstab</code>
#*In the editor, use the down arrow on your keyboard to move to last line, and then type '''/dev/sda1''' (change the "a" as necessary), then press "tab", then type '''/media/pi/my_short_name''' (change "pi/my_short_name" to whatever we used in our make directory command), then press "tab", then type '''ext4''' (again matching the format type we selected earlier), then press "tab", then type '''defaults''', then press "tab", then type '''1''', then press "tab", then finally type '''2'''
#*save the file (as described later in nano sub-section), hold down control key and press '''o'' letter key. Press "enter" again to confirm same file name.
#* exit nano by holding control key and pressing "x" key.


== Package Manager – a brief technical aside==

Linux operating systems install software by looking in repositories, and checking a register showing dependencies. When you ask Linux to install a particular package using “apt”, it also checks if all dependencies of the selected package are already present, and installs any that are missing.

If you look up on-line how to install any software in Linux, it may use “apt-get”, that is an earlier package manager, in general you can use “apt” instead now.

The full differences between “apt” and “apt-get” depends on your Linux flavour, so this technical aside now splits further discussion by Linux flavour.


''Don't forget to save the file under a new name, and copy it as instructed in previous subsection.''
===Debian as used by Raspberry Pi===


====Technical Notes only relevant to Raspberry Pi====
“Debian Linux” (and its derivatives such as “Raspberry Pi Operating System”) uses “apt” to mean a ‘’’Package Manager’’’ that can install, update, and remove packages from these computer systems.


This Wiki page has tried to avoid being too specific to particular hardware, but to avoid misunderstanding the last subsection, a little does need to be said to justify the claim that only technical users, who understand all the other changes needed, should make changes mentioned there.
For Debian Linux, “apt” is directed at the end-user (it has user friendly features like a staus bar showing progress on a long install or long upgrade, and can produce prompts about what it is doing and can give choices about whether to do individual actions).


A standard Raspberry Pi computer does not include a clock chip. Instead one of the packages it loads as a service on booting is called "fake-hwclock", and that sets the clock to what the date/time was when it was last running, irrespective of how many days/hours it has been off. That counts as a time sync for the purposes of instruction specified above. You can buy and fit a real-time clock chip, and configure your computer to use that, but even that RTC will only keep time when it is kept powered, and even then it will drift off unless periodically able to be corrected by a time from internet.
There is an alternative “apt-get” which is more powerful, but directed at system level users (those who don’t want to be watching progress and possibly responding to prompts).


The issue is your Cumulus MX on restarting will skip the catch-up of historic data (should your weather station settings make that available), because the dummy clock makes MX think the computer was not off for long. Subsequent measurements will then get logged against the wrong time until the correct time is found on the internet (NTP). At that moment, the time will suddenly jump, this is serious if this means the "rollover" time has been skipped over, as it implies the "dayfile.txt" will miss a line, and many measurements will be logged to wrong day. In my experience it can be anything from 2 minutes to 10 minutes after switch on before my RPi does a time sync over the internet.
As “apt-get” is updated less frequently than “apt”, it may be it will not work with new packages. Put another way “apt-get” may never change what it can do, but “apt” may get modified to do more than it did before.


You might expect <code>sudo systemctl disable fake-hwclock.service</code> (or remove the service, and modify the scripts that call it) could ensure the computer (if online) has to get a time found on the internet (NTP). Nothing is as simple as it might seem!
===Ubuntu===


===Commands to do actions on a service===
For Ubuntu only “apt-get” was available up to 2014, when “apt” was added. Both work as described above for Debian. Again “apt” is best to use.


You will need to start (or restart) MX after you have defined (or redefined) the service as instructed above. The specific commands to use with MX service are at [[Raspberry_Pi_Image#systemctl_commands|systemctl_commands]], here I simply repeat the basic commands that can be used with any service (status, enable, disable, start, stop, and restart).
===Mint===


Don't forget you may need to type <code>sudo systemctl daemon-reload</code> to tell "systemd" that it needs to reload all service definitions whenever either one has changed, or a new one has been added.
Linux Mint has a different variation. Its “apt” calls its “apt-get” and adds extra features. So both effectively do the same, but (as with previous flavours) “apt” is best to use.


In all these commands, '''just replace [service_name] with ''cumulusmx''''' (or enter the name of another service).
It is likely that other Linux variants will also vary how these alternative commands differ.
* <code>sudo systemctl status [service_name]</code>
** (displays whether named service has started, whether it has failed, whether it has stopped, also whether enabled, extra information will be added should status change)
** type the single character "q" to quit updating status display and return to prompt
* <code>sudo systemctl enable [service_name]</code>
** (typed just once, and service named will automatically start when your Linux computer is booted)
** the confirmation message says a link has been created
* <code>sudo systemctl disable [service_name]</code>
** (used when you don't want an automatic restart of the named service)
* <code>sudo systemctl start [service_name]</code>
** (will start the named service)
* <code>sudo systemctl stop [service_name]</code>
** (will stop the named service)
** Closing MX with "cumulusmx" as the named service this way does a proper shutdown
* <code>sudo systemctl restart [service_name]</code>
** (issues a stop, then start, command to named service)
** You can upgrade MX by installing new files over the existing ones, while MX is left running, and then use this command to pick up new release with minimum downtime.

Latest revision as of 08:38, 20 September 2023

Using MX on UNIX-derived Operating Systems

MX runs on any UNIX-derived operating systems (OS):

  • including those found on Apple Mac computers,
  • and those found on a multitude of devices running Linux.

UNIX is a long established operating system, and both UNIX and its derivatives have good long term compatibility. This means that commands are generally easy to learn just once and then you can normally continue to use what you have learnt.

Most devices also have a graphical user interface that can do the more straightforward tasks without needing to know all the commands.


Why install MX on Linux?

Contributions to the Cumulus Support Forum suggest that:

  • Use on a Raspberry Pi (RPi) computer is very popular
  • In general, people find installing, and running, MX on Linux is easy
  • The few people who do have difficulties are those who have good knowledge of Microsoft systems and therefore are so convinced they cannot cope with a swap to something different, that they give up too easily!

Microsoft has had a deliberate policy of being different to traditional computers (all others are mostly based on UNIX).

You may know that this Wiki started with a single page covering MX regardless on which operating system was used, that did not work.

If you are running MX on on any computer running the Microsoft Windows Operating System, then you should be reading the MX on Windows OS page instead. In the Cumulus support forum, there are many posts from people who are struggling with MX on PCs. It appears this is not because Microsoft computers are so more readily available and therefore known about; but because people often find “installing”, and using, MX is more difficult when using the more complex Microsoft Windows operating system, and people tend not to understand basic issues such as avoiding "Program Files".


Cumulus Version MX SpecificThis page focuses on aspects of MX that are specific to the Linux operating systems.

Still believe it will be too complex for you? The developer has created an image you can download for those prepared to run two computers (a RPi for actually running MX and another computer for all interactions with MX). Read all about it, on Raspberry_Pi_Image page, and decide if that is for you.

Device Coverage

Linux is available based on a multitude of different kernels (the building block for the operating system), on a multitude of devices.

This page has been originated by a contributor using the Raspberry Pi Operating System (this is based on Debian, one of the Linux kernels). Be aware therefore that some instructions on this page are specific to a Raspberry Pi computer with its default operating system.

For other devices, the inclusion of the correct instructions is totally dependent on whether any contributor has edited this page to cover your device in the context of that section of this page. It is hoped that contributions to this page will be made by Cumulus users with a range of different devices so this page is useful to more people.

Until somebody creates a separate page for Apple Mac computers (that could be a good idea, as there are some significant differences), this page is the best source of advice.

Further Information

There are various related pages to get more information:

  • If you encounter a problem when running MX, please see What to do when I have a problem with MX
  • If MX gives you a message saying "you are not running the latest version", please see Guide to upgrading MX
  • If you are puzzled by the terminology, please see Category:Terminology for links to pages that explain terminology used by Cumulus (these pages were written for the legacy Cumulus 1 and may need updating for MX)
  • If you need to know more about files in the installation, please see Category:Cumulus Files for links to all Wiki pages describing the sub-folders and files used by MX
  • Go to Category:Cumulus MX for links to all pages in this Cumulus Wiki that relate specifically to MX
  • Admin interface provides information on configuration and web pages for viewing your weather data locally
  • The Cumulus MX FAQ page was created with snippets from the forum, but nobody has yet sorted this out into a useful page or updated it for recent releases
  • If you were using the original (now legacy) Cumulus software, please read Migrating_from_Cumulus_1_to_MX, although that is mostly directed at those using MX on the same Windows PC as they used for Cumulus 1, and was written for an old MX release, it will help you understand configuration differences.
  • If you want to use a script language, you might want to read PHP Hypertext Pre-processor and JavaScript page
  • If you will be using the standard web pages (from release 3.10.1) see this page
  • If you want to write your own customised templates, read Customised_templates.
  • If you want to explore alternative web pages from third-parties, start on User Contributions page.


Preparing your computer for installing the Cumulus MX suite

Please see Preparing your Linux computer for MX page if you have not installed MX on Linux before.

That page covers:


Please be advised some of the above is rather technical reading, but Mono is required to run the Cumulus packages described next. So do ensure that you installed Mono before continuing.

Technical aside

Please note this Wiki page talks about "folders" for compatibility with the MX on Windows OS page, but Linux prefers to call them directories.

Linux has a well defined filesystem, represented as a hierarchic tree starting at the root "/", that is divided into directories (one of which will be "/boot" and hold the kernel), each of those first level directories can be divided into second level directories, this second level is sometimes referenced to as defining the "scope", an indication that each is meant to be used for a specific purpose. The scope can be sub-divided again at lower levels representing "categories" (categories cover items like binary code, documentation, configuration, hardware, source code, runtime and content), and at a lower level still "applications" (i.e. related to specific programs) with further sub-levels for various options within those applications. Many Linux distributions will use logical links so references to a directory at one level in the hierarchy will actually redirect to files in a different directory, this might be because different programs expect to see files in different places or just to enforce ownership and writing rights.

For the purposes of this Wiki, the terminology "operating system" is used for the whole Linux distribution, you will find that Linux technical people prefer to talk about Linux distributions including:

  1. a "kernel" for the underlying handling of files, network and so on;
  2. one or more "shell" components for the handling of commands entered in terminal mode, including those that run programs (whether included in distribution or added later);
  3. an optional graphical user interface for simpler access to commands and programs.

For simplicity the terminology "terminal" is used for how you access the shell, this term refers to seeing the command prompt if your Linux is running without a graphical user interface, or to a window that you can open within the graphical interface where commands can be typed. Depending on your Linux, that window might be called "Terminal", "Konsole", "xterm", "gnome-terminal", "uxterm", or even something else. If you are accessing your Linux computer over a network from a computer running Microsoft Windows, then again you may encounter a number of terms for how to access the shell on your Linux computer, "Command Window", "Windows Powershell", or "Windows Terminal". Equally you may use software that calls it a teletype mode, e.g. PuTTY software.

Cumulus packages

  • This section covers:
    • CumulusMX.exe
    • ExportToMySQL.exe
    • CreateMissing.exe

(At time of writing this "CreateRecords.exe" is proposed, and under development, but not released).


Handling zip files

Each release is presented as a zip. It does not matter which device (if you have two or more computers), or which browser (it can be default browser for your device or the browser you like best) you use for the download. When your browser saves the zip it might be into a folder called “downloads” on your computer, or you may be able to save into another folder that you prefer (perhaps on a different partition). Your browser might even remember the folder you used before for files of type zip.

In general, any device will load a suitable application to use to unzip the package when you click on a filename that ends in .zip. You might need to do a "right click" and choose the application, it depends on your settings.

Be aware, you may need to adjust the settings within that application for how it handles the file structure. The preferences may determine whether the unzip process preserves the file structure used when the zip was created (i.e. each file remains in any sub-folder) or it ignores the folder structure. For the Cumulus context, it is essential to preserve the folder structure. You may also be asked where you want the files to be extracted to, or the default settings might always use a particular destination (and that might be a tmp folder).

For example on the Raspberry Pi operating system, there is a package called xarchiver, in its Graphical User Interface (GUI), there is a menu called "Action", and the final option in that menu is "Preferences". There, in "Archive" section, you can select "zip" as the preferred archive format (using a drop-down) and whether you want the application to confirm with you before deleting any files; in "Advanced" section, you can select the directory to use for the extraction. If you are using the lite version of the RPi OS, then you need to edit the /home/pi/.config/xarchiver/xarchiverrc file to set preferences, before you use the archiver package. Once you have started the archiver package, and told it which file to process, you can click on Extract files, the GUI presents a screen of options:

  • "Extract to:", use the icon to browse to the required location if it has not been set up in preferences
  • "Ensure a containing directory", tick this if it has not been set in the configuration file
  • "Files", select "All files", the advice is to overwrite all of any existing files if you are upgrading, but you definitely need all files if this is a new install
  • "Options"
    • Tick "Extract files with full path", this is essential if you are going to successfully install any of the Cumulus software
    • Tick "Overwrite existing files", the advice is to overwrite all of any existing files if you are upgrading, it may not always be clear which files have been updated since an earlier release, and there are a lot of interdependencies between different files

It is worth stressing here, if you decide to customise any files that are included in a release distribution, then you should at the very least add something like an "_" character to the file name to make your tailored file different to the standard file. The best practice is to put any files you tailor, or any additional files you create, outside the CumulusMX folder.

If you have chosen to do the download on a different device to that on which you will install, you can unzip on either device. To transfer either the downloaded .zip file, or the extracted file structure, between devices, you can use a file transfer package, or use a portable drive (a memory stick or even a memory card) with a partition formatted so that you can read it on both devices. Windows and Linux partitions are formatted in different ways. While it is likely that Linux can read a Microsoft formatted partition, Microsoft Windows can never read a Linux formatted partition.

Where to install all packages?

For simplicity on this page CHOSEN PATH (the contents of this will start with a slash “/”, but not end with a slash) is used to represent any location in the Linux file structure where you decide to install all the Cumulus packages.

The phrase “CHOSEN PATH” is used, because it is most likely you want to create the sub-folder called “/CumulusMX” (note where capital letters must be used) in a part of the Linux file structure that already exists.

It is important to minimise the length of the path name, because this path name has to be passed between various different software languages (and longer paths risk truncation).


Creating the CumulusMX sub-folder

  • You can create sub-folder called “/CumulusMX” as you unzip a MX release, or you can type sudo mkdir CHOSEN PATH/CumulusMX first (note that CHOSEN PATH is explained above and always starts with a slash “/”).
  • By using the phrase CHOSEN PATH this advice avoids telling you to install Cumulus where you do not want it:
    1. Many people with a Raspberry Pi, and a little technical understanding, add an external drive to reduce wear on the internal micro-SD card, and keep their Cumulus files away from the drive that holds the operating system.
      • This page is not going to get technical by telling you how to create, or mount, Linux partitions on your external drive. If your drive was bought from a Raspberry Pi reseller, they might help you.
    2. Other people using a Raspberry Pi without that technical expertise, might use ‘’’/home/pi’’’ for CHOSEN PATH as that is the default folder for the default user (Pi) and can be referenced as "~" in file path instructions they issue (although Cumulus will not understand that shorthand)
      • Within that ‘’’/home/pi’’’ folder, the default user has full permissions automatically.
    3. The developer suggests you use ‘’’/opt’’’ for CHOSEN PATH (which should be available on any Linux computer).
      • By default, the code Mark provides for installing Cumulus as a service, will run that service as a root user, and the root user has full permissions in /opt (and everywhere else)
      • (Novices: Skip this step) If you do choose a CHOSEN PATH outside your home folder, then a more technical user can change the ownership of the "CumulusMX" sub-folder, to the default user (Pi) with sudo chown -R pi: CHOSEN PATH/CumulusMX, and reduce the need to use "sudo" on many actions.

Packages to install

We shall install the Cumulus software listed on Software page:

  1. CumulusMX:
  2. Create Missing:
  3. ExportToMySQL
    • ExportToMySQL.exe is also written in C# by Mark Crossley
    • Download Export To My SQL zip file from the link at Software#ExportToMySQL
      • This takes you to a github page with a "ReadMe" providing minimal instructions
    • ExportToMySQL.exe is not (at the time this was written) documented in this Wiki although MX_Administrative_Interface#MySQL_settings does describe a similar utility (written by Steve Loft) that was actually included within early CumulusMX zip downloads.

As at 9 March 2020, another utility, CreateRecord, has been initialised in the Github areas managed by the developer where Cumulus is worked on, although it appears to be just a concept on github. This will, if my understanding is correct, read dayfile.txt and use that to update the various extreme record files. The developer is still aiming to make this available, but his work on it (on his computer) has been stalled by the level of pressure being applied for bug-fixes and changes to MX itself.

Alternative download link for older package releases

Because the developer uses Git Hub to manage releases, the older releases remain available.

Old Cumulus MX packages

Skip this subsection if either you have installed the "pre-built disc image", or the current MX release is stable (it has been available for a while and nobody has reported any bugs).

Check if posts in the Cumulus Support Forum tell you that the current release of MX has one or more bug(s) that affects one or more aspect(s) of MX that you intend to use.

Remember, it is impossible for the developer to check all the ways in which versatile MX can be used:

  • Different weather station types (the developer only has a Davis),
  • Different computer types (development is mostly on Microsoft Windows),
  • Plus a whole host of optional features, and different external upload sites, (typically each of these optional features are only used by a sub-set of Cumulus users).

Anyway, you can download any earlier MX build, without the bug, from CumulusMX/releases.

Old utilities

The zips for "CreateMissing.exe" and "ExportToMySQL.exe" utilities do NOT contain the .dll components that they need when they are running.

This means that each version of "CreateMissing.exe" and "ExportToMySQL.exe" utilities is dependent on it being used with a release of Cumulus MX that does have correct .dll components in its release distribution.

That in turn means you can't use the latest version of the utility with older MX releases, nor can you use an old utility version with latest MX release. This is why utilities downloads make clear which MX release is the minimum for them.

The older versions of these "CreateMissing.exe" and "ExportToMySQL.exe" utilities are available by going directly to the Cumulus MX github page, and navigating to the utility of interest. However, to use those older versions, you also need to download the corresponding older MX release, because the MX distributions contain the .dll files that the utilities require, they are not in the utilities zip. Because of this complication, novice users are advised not to attempt to use the older utilities, even if the latest version appears to have a bug. Technical users may be able to work out which .dll files are needed and can be safely added back (if they are not left over from when that past MX release was in use). An alternative is to create a new folder with the old release packages (MX and the utility of interest), a copy of the latest Cumulus.ini file, and a copy of all files from /data sub-folder; then afterwards copy back the changed files into original /data folder.

Upgrading a Cumulus package

Always check the release announcements in Cumulus MX announcements for any action needed in planned upgrade. In brief, all files from new release distribution replace the files from previous release, and the download/unzip is as covered above.

No further action needed for upgrade of "Create Missing" or "Export To My SQL" or "Create Records". See below for upgrade of main Cumulus MX package.

If you are running an older MX release, before skipping in-between versions please check here.

If you run MX as a service, then:

  1. Ensure you are not doing any changes to settings
  2. Leave MX running as you copy files from the new release distribution over the existing files
  3. Try to pick a time just after MX has done any standard interval store of readings or upload, so that it is least busy
  4. Use sudo systemctl restart cumulusmx to stop and then restart MX picking up the new files
  5. Result, downtime of MX kept to a minimum, so avoiding losing data

If you run MX interactively, do the unzip into a temporary location before you stop MX, then copy all files from temporary location over your existing files, and finally restart MX. Depending on your weather station type, it might or might not offer historic data catch-up, so you might lose some data while MX is stopped, and therefore should keep the downtime to a minimum.

The alternative is to install in a new folder (or rename the old one), and copy across files not in the release from old location to new location, but in that alternative you might forget some files.

Changing location of Cumulus MX

If your install, or upgrade, is creating MX in a different place to where you previously ran Cumulus, then you will want to copy files across that are not in the zip extract distribution.

Configuration Files to copy across from any previous Cumulus installation

There are two configuration files that are not included in any MX release:

  • strings.ini (note all lower case) – optional file to customise output
  • Cumulus.ini (note initial capital, then lower case) – main configuration file

Here, it must be stressed that having either or both of these files in an existing Cumulus installation does not imply such file or files can be understood by the new MX release you have just installed.

Just copy the existing files from old to new installation, if

  1. Your locale is still the same
  2. All files on your new install are in same paths as on your old install (some settings involve specifying paths)
  3. Your old installation has a relatively recent MX release (compare the "y" in 3.y.z,between old and new installation, a difference of more than 1 in that middle figure means you do not have a recent release)
  4. Your old installation was on a Unix-based computer (not a computer running Microsoft Windows Operating System)

Please see the table below for more advice, but the problem is that content of both files has changed as MX has been developed, so some content is no longer understood, and some new content has been added.

Some of the differences between versions of Cumulus.ini file can be seen by comparing the different pages in this Wiki documenting this file: Cumulus.ini (Beta), Cumulus.ini (Cumulus 1), Cumulus.ini (MX 3.0.0 to 3.7.0), Cumulus.ini (preserving history), and Cumulus.ini, but even that does not tell the whole story. MX release 3.12.0 needs to be installed if your old Cumulus was earlier than that, because it is the only release with code to rename the old "Cumulus.ini" and create a new file containing the new set of settings, and new names for some old settings, but without any old settings that are no longer recognised. Please see Updating MX to new version page for more information about the need to step slowly through from old releases to the newest.


If you are upgrading from an older release, please read the table for advice.

Cumulus.ini strings.ini
Your old installation will have this file. In general, if your old installation was any release before 3.8.0, the advice is give the old file a different name when you copy it across to the new installation, and let MX create the file as you work through all the settings. This is an optional file. Its purpose is to allow customisation of some of the outputs from Cumulus. You might want to use customisation to abbreviate (or extend) some outputs, or to change those outputs into another language.
When you work through the Settings pages, MX will create this file if it does not exist.
  • See #Moving from Microsoft Windows to Linux if your old installation is on a Microsoft operating system, as several changes will be needed for extra web file settings on your Linux computer
  • If your old installation was of the legacy software then also see Migrating from Cumulus 1 to MX
  • As MX evolves, the former "read-only" settings in this file are becoming "advanced" settings in the interface.
You create a “strings.ini” file by selecting some of the parameters from the Samplestring.ini file that is included in each MX release, and modifying the value for the listed attributes as you type just those you selected (under the same group titles - these are enclosed in [ ] as before).

The sections that appear in samplestring.ini, and the parameters that appear within a section, depend upon which release you are using. So be cautious if you try to reuse a "strings.ini" file originally created by the legacy software, you may find you need to specify your customisation using different parameters in the latest "samplestring.ini".

The content of "Cumulus.ini" is changing as MX is developed, the Release Announcements normally list any new parameters as they appear in the file, without always mentioning those that have become redundant. The announcements tend to avoid any detail, so you have to guess from the attribute what values it might take, and generally have no idea of where in the settings pages to make any change.

To remove any parameters no longer used in this file, see remove redundant parameters

If your old file contains any legacy read-only parameters not yet converted into advanced settings, or any MX read-only parameters not yet converted into advanced settings, you may need to manually add such missing parameters back into new file by stopping MX (after finishing all the settings you can configure in the interface), doing an external file edit, and then restarting MX.

The content of "samplestring.ini" is changing as MX is developed:
  • Therefore, your existing “strings.ini” might need to be modified.
  • There is no automatic way to check your “strings.ini” file, if MX does not understand any parameter in this file, it ignores it.
  • Instead, you need to manually check each parameter you have in your “strings.ini” file to see if that parameter is still in the “samplestring.ini” included in the release you have installed.
  • You may also find new parameters in “samplestring.ini” that you wish to add to your “strings.ini” file to tailor new functionality to your preferences.

If you previously used an older release of Cumulus, but in this new installation will be using the latest release (latest is what is normally best, unless it has bugs), you may want to read up on all the changes between your old release and the current release, not just changes that affect the configuration file.

If you have used Cumulus 1 before, and decide to start with a new "Cumulus.ini" file, then you will need to work through all settings, to ensure they are set as you want. Please remember that when you use MX for first time, it uses that date it was first run as a starting date, and ignores any data found with earlier dates. Therefore you must change that start date: MX interface --> Setting menu --> Station Settings --> Click on General Settings --> Click on Advanced Options --> Edit Records Began Date following instructions below that field

"data" directory

Please see Category:Files_with_Comma_Separated_Values, Category:Ini_Files, and Weather_Diary, for information if you are moving from Cumulus 1 to MX. Otherwise just copy files from any existing folder to your new one.

You may also wish to read:

    • Amending dayfile tells you about how MX is far more fussy about the content in dayfile.txt
    • .ini files explains how time-stamps are formatted differently in the extreme tracking files
    • Migrating from Cumulus 1 to MX gives some advice about differences in settings, but be aware that the way MX handles settings varies by release, and information on the linked page may be out of date

Complications occur if the locale used by Mono or the locale specified when starting MX using -lang parameter differs from the locale for your previous device (please see Category:Files with Comma Separated Values because some locales separate fields with commas, some separate integer and decimal parts of real numbers with commas; not to mention all sorts of issues with how dates are formatted). The main MX developer proposed that the format of files with comma separated values will be fixed from a release planned for September 2020, so all dates will use one standard format, all numbers will use decimal points, and the field separating character will be fixed.

Update May 2022, this has been put on hold, no public MX release has this restriction yet.


"Reports" directory

By default MX now creates monthly and annual reports that are in the style used by NOAA in USA. If you have been using this functionality before (and it is optional) then you need to file transfer, or copy, all the files that were in the old Reports folder into the new folder of that name. Do look at that cross-reference, and read about the encoding default differences between Cumulus 1 and MX.

MX can cause problems with storage

MX now assumes by default that you are going to use its Default Web Site. That means that by default MX will re-generate temporary files in its /web sub-folder on a frequent time-scale. That number of files writes will considerably shorten the working life-time of the "high capacity micro-SD" card that is the default storage for the Raspberry Pi. It will also considerably shorten the life of any flash memory (e.g. memory card) that you might install MX on.

The expected life of any storage device, and the extent to which its life is shortened depends on the actual device. The external devices that have the longest life (and therefore can cope most easily with multiple read/write actions) are solid state discs (SSD). Also the larger the capacity of the storage device, the more places on the device where files can be stored and the storing algorithm will try to spread the storing evenly across the entire storage area, so wear at any one location is reduced.

All Linux computers will have some random access memory chips (RAM) and it is worthwhile to define part of that RAM as a drive used for temporary files. For a Raspberry Pi computer, a typical approach would be to edit the fstab file, adding the line tmpfs /run/tmp tmpfs nodev,nosuid,size=1M 0 0, but the size you choose will depend on RAM available and what temporary files are being created. For maximum life of the "high capacity micro-SD" card if that is what your computer boots from, you should create a symbolic link path that maps the /tmp folder used by the system to your /run/tmp you have just defined in RAM. The difficulty will be that you cannot create a logical redirect on /tmp if the folder is already in use, so that makes it too complicated to explain here.

web directory

All the files in this folder come from the download.

However, when you are running MX, it may try to create temporary files here, and following the advice above, you may decide to set up symbolic links so any attempt to create a temporary file in the "web" folder is redirected to the temporary folder you set up in RAM.

The links you need depend on which options you select in settings, you might find it easier to wait until you have run MX for a while to see what files are created that end in ".json".

If MX is currently running, you need to stop it, or at least alter any options that generate .json files. Then you must delete those files that end in ".json", except that you don't delete "websitedataT.json".

In a terminal session, issue commands in the following format for each file (this example relates to Raspberry Pi and uses "/var/tmp" which was defined in the extra line added to fstab earlier):

sudo ln -s /run/tmp/websitedata.json CHOSEN PATH/CumulusMX/web/websitedata.json

Notes:

  • The "-s" flag is what says you are creating a symbolic link
  • Full paths are given both for the file that MX is to be redirected to, and after it the path where it expects to create the file
  • "CHOSEN PATH" is defined in #Where to install all packages?, but basically it starts with a "/" and defines the path to get to where "CumulusMX" is a sub-folder.
  • The text "websitedata.json" is just one file in the set of files linked from Category:JSON Files.

Running MX

There are multiple subsections here, you are unlikely to need to read them all. Look at each, and decide if it applies to you.

Parameters

CumulusMX.exe can take a number of optional parameters as summarised here:

Parameter Description
-port nnnn This parameter can be used whether MX is running interactively or as a service. Used to change the port where the web server for the MX interface runs, when Cumulus starts, it will display the URL of the interface where you change the settings, this is port 8998 by default. To use it when running MX in interactive mode, type sudo mono CumulusMX.exe -port 9999 and the interface will run at port 9999 instead.
-service This parameter is not available when running interactively. It is used in a service definition file, please see #Running MX as a Linux "systemd" service for all details
-lang {locale} This parameter can be used whether MX is running interactively or as a service. Used to change the locale that MX will use from the default on your computer. To use it when running MX in interactive mode, type sudo mono CumulusMX.exe -lang en_GB</code. There is a list of locale codes at http://msdn.microsoft.com/en-gb/library/ee825488%28v=cs.20%29.aspx. Remember this changes whether MX uses decimal comma or decimal point (although the intention is that all Cumulus files will use decimal points, this will still affect the output from api calls, web tags, etc.) and how it names files that include letetrs representing a month abbreviation.
-debug This parameter can be used whether MX is running interactively or as a service. This is only available for release 3.4.4 - Build 3068 onwards. This switches on debug and (from 3.1.0) data logging from the start-up of Cumulus MX. Please note this increases size of files created in MXdiags_folder. As an alternative to using this parameter, you can switch debug and data logging on and off within the MX interface settings, see the aforementioned link for instructions.
-wsport Applied to MX beta 3.0.0, no longer available, set the port for web sockets, now incorporated into the -port parameter.
-logging Applied to MX beta 3.0.0, no longer available, enabled just data logging, now incorporated into the -debug parameter


Your first run of MX on Linux

Once you have got all the files sorted out as described above, you need to run MX.

On the first run of MX, unless you have run a recent release before, you need to work through either the Config wizard or all the individual settings pages (or both) as accessed from "Settings" menu. It is suggested you run MX interactively (see below) to do this, as you will then need to close MX, and then start it up again.

Information about settings is on other Wiki pages (MX Administrative Interface and Cumulus.ini).

Run interactive or as a service

MX can be run in two different ways.

It is advised that you run MX interactively to begin with, and only run it as a service when you are happy that all settings are correct, and that any uploading or other external tasks are working correctly.

Running interactively allows MX to display error messages to you, and to confirm when it is running normally. Just in case it is not obvious .... if you start any executable interactively in a terminal window on your Pi, you must leave that session running, or that executable will stop running

If you run MX as a service you do not get any direct feedback, and cannot see if there has been a problem or failure. Running as a "systemd" service was first made available at Patch release 3.8.4 - b3094 (14 September 2020).

Running MX interactively

To run MX interactively, you must open a terminal window, and leave it open until after you have closed MX.

The simplest instruction to run Cumulus MX is cd CHOSEN PATH/CumulusMX && sudo mono CumulusMX.exe [optional parameters].

  • This is two commands issued together, the first changes the working folder, the "&&" means that first command has to succeed before the second command is obeyed and actually starts the main executable
  • This example has not included any optional parameters, as they are rarely needed, but the optional parameters available are as listed in table earlier.

When you want MX to stop, you must (for Linux) within your terminal session hold down the "Ctrl" button on your keyboard, and press "c". A word of caution here, if you are accessing your Linux computer over a network from another computer, do be careful about using any control sequences, as it is possible that your "Ctrl" "C" sequence will be applied to an application other than Cumulus MX, if that terminal session has started more than one application. The issue is that all running applications use the same terminator, it should be applied to whatever is regarded as the "foreground" application at the moment the control key sequence is used, which is guaranteed to be MX if that terminal session has only been used for running MX, and MX has not launched any external applications. After that you can choose to close the terminal window.

Interactive advice

If you have followed advice at #Where to install all packages?, the user you are using will own the "CHOSEN PATH/CumulusMX" folder and you may be able to omit the "sudo" befor the "mono". I say "may" because there are other reasons why you may need to run as root user, too technical to explain here.

You can start it off directly on your Pi, and then

  • optionally disconnect the keyboard,
  • switch off monitor or TV attached to your Pi,
  • Just ensure you leave Pi on (with that window minimised) so that terminal session continues running.

Running MX interactively from a remote computer

This is similar to running a terminal session on the machine that you installed MX on. If your remote computer is running Microsoft Windows, then the option to run a terminal session, may be called "terminal", "powershell window", "command window", or you might install software such as "PuTTY" to provide the teminal (TTY is the abbreviation for "teletype", a device that was commonly used to access computers in the 1970s and early 1980s).

These won't be explained any further here, but be aware that control key sequences may not work, and you may need to type "exit" to close the session.

Use ps -ef | grep -i cumulus | grep -v grep to see if Cumulus is running or not.

Running another executable with a terminal session left open

Open a terminal window, then navigate to the folder where you have installed the 3 Cumulus executables:

To run "Create Missing utility" type cd CHOSEN PATH/CumulusMX && sudo mono CreateMissing.exe. It does not take any parameters, so that is all you need to know, although it is fully documented at Calculate_Missing_Values#CreateMissing.exe in this Wiki.

To run Export To My SQL, you change the name of the executable above and add the necessary parameters, follow that link for more details.


Running MX as a Linux "systemd" service

There is a one-off task to define a service file, after that you can simply issue commands to stop/start/restart the service.

For more information, see original release announcement.

The Service definition file

The MX download includes a file that can be used as a starting point for the service definition. Find this file at CHOSEN PATH/CumulusMX/MXutils/linux/cumulusmx.service. You do have to edit this file, and then you have to copy it to a new location, before you start the MX service for the first time.

  1. Open the file at CHOSEN PATH/CumulusMX/MXutils/linux/cumulusmx.service using an editor (see editing_files).
    • On a Raspberry Pi with a graphical interface, use the file manager to navigate to this file, right click the file named, and select "Geany's Programmers Editor".
    • If you are accessing from another computer, using a terminal session, then "nano" is a suitable editor (explained at link just mentioned).
  2. Within the provided file you should find a [Service] section:
[Service]
User=root
Group=root
ExecStart=/usr/bin/mono-service -d:/home/install/CumulusMX CumulusMX.exe -service
Type=forking
ExecStopPost=/bin/rm -f /tmp/CumulusMX.exe.lock
  • Be aware that what quoted above applies from MX 3.16.0 (b.3182, 30 Apr 2022) onwards, earlier releases did not include the "-f" flag in final line quoted above.
There is more in the file, but for now focus on the line including "ExecStart=/usr/bin/mono-service -d:". Don't change any of the bit I just quoted.

Almost certainly you will need to change "/home/install/CumulusMX" on that line. Replace that with "CHOSEN PATH/CumulusMX", i.e. the full path to the directory that the executables are being stored in.

The final line, with all possible parameters, could read: 'ExecStart=/usr/bin/mono-service -d:CHOSEN PATH/CumulusMX CumulusMX.exe -service -debug -port 999 - lang el-GR

  • Note the space between the path (just looked at) and the executable file,
  • Note the mandatory parameter "-service" that follows a space after the "CumulusMX.exe", you must leave that untouched,
  • Note you can remove/keep the rest of the line after the -service i.e. the other parameters (some with their values) -lang, -port, or -debug, (as defined in table earlier), are all optional.


Technical user may do other edits on the file, these will be described later, for now save the changed file under a new name (so it won't be lost when you do a MX upgrade that replaces original file) within your MX installation:

  1. Open the "File" menu, and select "Save as" and enter a new name cumulusmx_edited.service
  2. Exit out of the editor you are using
  3. Next, open a terminal session
  4. Now copy file to where it is needed to run the service sudo cp EXISTING_PATH/CumulusMX/MXutils/linux/cumulusmx_edited.service /etc/systemd/system/cumulusmx.service
  5. Now type sudo systemctl daemon-reload, this tells "systemd" that it needs to reload all service definitions because either one has changed, or a new one has been added
  6. Finally, optionally, create a symbolic link to that file using sudo systemctl enable cumulusmx if you want the service to automatically start after a reboot


Technical users - additional edits

Novice users, skip this subsection. The changes in this subsection have to be made with other changes that are not covered here (they depend on your weather station type, and your computer type, so are not appropriate to a Wiki page trying to generalise, and anyway your contributor is not a technical expert).

Look at the [Service] part of the file quoted above.

This states Cumulus should use root for both the user it runs under and for the group permissions it uses. If you have the technical expertise, you might choose to run MX in a different user, if your weather station type allows MX to run in a different user. If so, replace the "root" in its two locations. (Please note some weather stations require other changes outside this file before Cumulus can make contact, one example is discussed on support forum here, but there are other topics that may be relevant).

You may also wish to add an extra line after the "Group" line ExecStartPre=/bin/sleep 5, this is to delay the starting of MX by 5 seconds while other services start (on a reboot of your computer) that might affect MX. (For some users, change 5 into 10, it all depends what else is being started).

Look at the rest of the file, the [Unit] part.

For releases 3.8.4 to 3.15.0: you will see one reference to network-online.target in After=network-online.target.

For release 3.15.1 build 3170 (19 March 2022) onwards: you will see an extra line Wants=network-online.target

If you are a technical user, you might decide to edit the [Unit] part of the file, you have to decide what is needed in your context, only you know what other services are started by systemd on your computer, you can list all items using something like systemctl list-unit-files to see the services, but you still need to understand what each does.

If your computer has online access, then it can look up the correct time online and adjust its clock. However, it might not even try to do that for say 10 minutes after being booted, and so there may be a benefit in making MX wait until after systemd has asked for the time to be synced, and asked that the local file-system is made ready so MX can read/update/store files. To achieve this, you might choose to add a blank line after Documentation=https://cumuluswiki.org/a/Main_Page and in that blank line, type Requires= time-sync.target local-fs.target. Using "Requires" ensures these requesting events have happened before MX can start, if they fail, MX will not be started, this example has not specified a time that MX should wait for the other services to start!

For that time-sync.target to work, you need to enable, by creating the symbolic links needed, the appropriate services outside this edit:

sudo systemctl enable --now systemd-timesyncd.service
sudo systemctl enable --now systemd-time-wait-sync.service


Here is a quick explanation of all entries in this UNIT section:

  1. Entries
    • The terminology "After" tells "systemd" that what is named can be started after MX, in this case it does not guarantee that the network service (to send data to a remote web server) will be started
    • The terminology "Wants" tells "systemd" that what is named is wanted now, i.e. try to start before MX, but still start MX even if the starting of the network service fails.
    • The terminology Requires tells "systemd" that the "cumulusmx" service should not be started until the services specified on that line have successfully started
      1. The local-fs.target specifies that the cumulusmx service requires the file service to have started, i.e. checks your computer can read files before it attempts to start the cumulusmx service
      2. The time-sync.target specifies that the cumulusmx service requires the computer to have synced with some time source (see notes below), which could be useful if your weather station type does not time-stamp readings stored in the console, and you want to ensure MX reads correct time from your computer

Don't forget to save the file under a new name, and copy it as instructed in previous subsection.

Technical Notes only relevant to Raspberry Pi

This Wiki page has tried to avoid being too specific to particular hardware, but to avoid misunderstanding the last subsection, a little does need to be said to justify the claim that only technical users, who understand all the other changes needed, should make changes mentioned there.

A standard Raspberry Pi computer does not include a clock chip. Instead one of the packages it loads as a service on booting is called "fake-hwclock", and that sets the clock to what the date/time was when it was last running, irrespective of how many days/hours it has been off. That counts as a time sync for the purposes of instruction specified above. You can buy and fit a real-time clock chip, and configure your computer to use that, but even that RTC will only keep time when it is kept powered, and even then it will drift off unless periodically able to be corrected by a time from internet.

The issue is your Cumulus MX on restarting will skip the catch-up of historic data (should your weather station settings make that available), because the dummy clock makes MX think the computer was not off for long. Subsequent measurements will then get logged against the wrong time until the correct time is found on the internet (NTP). At that moment, the time will suddenly jump, this is serious if this means the "rollover" time has been skipped over, as it implies the "dayfile.txt" will miss a line, and many measurements will be logged to wrong day. In my experience it can be anything from 2 minutes to 10 minutes after switch on before my RPi does a time sync over the internet.

You might expect sudo systemctl disable fake-hwclock.service (or remove the service, and modify the scripts that call it) could ensure the computer (if online) has to get a time found on the internet (NTP). Nothing is as simple as it might seem!

Commands to do actions on a service

You will need to start (or restart) MX after you have defined (or redefined) the service as instructed above. The specific commands to use with MX service are at systemctl_commands, here I simply repeat the basic commands that can be used with any service (status, enable, disable, start, stop, and restart).

Don't forget you may need to type sudo systemctl daemon-reload to tell "systemd" that it needs to reload all service definitions whenever either one has changed, or a new one has been added.

In all these commands, just replace [service_name] with cumulusmx (or enter the name of another service).

  • sudo systemctl status [service_name]
    • (displays whether named service has started, whether it has failed, whether it has stopped, also whether enabled, extra information will be added should status change)
    • type the single character "q" to quit updating status display and return to prompt
  • sudo systemctl enable [service_name]
    • (typed just once, and service named will automatically start when your Linux computer is booted)
    • the confirmation message says a link has been created
  • sudo systemctl disable [service_name]
    • (used when you don't want an automatic restart of the named service)
  • sudo systemctl start [service_name]
    • (will start the named service)
  • sudo systemctl stop [service_name]
    • (will stop the named service)
    • Closing MX with "cumulusmx" as the named service this way does a proper shutdown
  • sudo systemctl restart [service_name]
    • (issues a stop, then start, command to named service)
    • You can upgrade MX by installing new files over the existing ones, while MX is left running, and then use this command to pick up new release with minimum downtime.