|
|
Using CRON and SSMTP to perform scheduled tasksI'm lumping these two programs together as you'll probably want both: cron is a scheduler. It accepts instructions from one or more job files. Each instruction consists of a date and time and a command to be run at that date and time. If the command returns text then this can be sent as a report via email provided the system has a mail service installed. Without an email service you might need to send all output to /dev/null to avoid dealing with log files. Another solution might be to send command output to "syslog", but I don't know how to configure that. ssmtp is a cut-down mail sender. It simply forwards all messages to another server capable of delivering them. Typically that would be your ISP's mail server. This is an alternative to a full-blown "sendmail" implementation, and is the preferred choice when using an internet connection with a dynamic IP, such as a typical home account. The cron package installs fully, including the startup scripts it needs and a start command so if you've just installed it then it will be running now. The only configuration you should need to do for cron is to actually set some jobs. ssmtp usually needs a bit of configuration as it needs to know what address to send to and who it is sending as. By default it attempts to construct an email address using user-name@machine-name, but this is unlikely to work on a small LAN-based server, so you need to feed it some valid addresses. To fault-find email sending it is possible to install a mailserver on another machine, for example a windows PC. By setting the PC as the mail hub and setting the domain to "*" the PC server can be set to accept any email routed to it and that way you can diagnose a configuration problem. Don't worry about spam-email as this all takes place locally and can't be reached from the internet. |