How to Automatically Update Stata on Linux
On Windows and macOS, Stata can be configured to check for updates automatically with the set update_query
command. However, there are a few drawbacks to this approach.
For one, this feature isn’t present on the Linux version of Stata. For two, this command doesn’t actually update Stata — it just enables update notifications. Stata will still need to be manually updated by someone with the permission to do so.
If you’re running Stata on a standalone Linux server or an HPC cluster, you may be interested in having Stata update itself without any user interaction. This is especially useful if Stata users do not have permission to update the software themselves, as is often the case on shared Linux systems.
We can enable true automatic updates with a cron job and a Stata batch mode hack:
0 0 * * 0 echo 'update all' | /usr/local/stata16/stata > /dev/null
Adding this line to root’s crontab will cause the update all
command to be run every Sunday at 12am. Standard output is piped to /dev/null
to prevent cron from sending unnecessary emails.
As always, think carefully before enabling automatic updates for mission-critical pieces of software. However, this approach can save time over updating Stata manually.
Leave a Reply