With cloud services like AWS EC2, you can quickly set up a Linux server and run software on it, like LAMP/LEMP, Node.js, etc. However, to run a server for months or years, there are a few things you can do to minimize required maintenance.
Usually Linux servers can run for long time without having to reboot or cleanup, unless the software you run on it consumes too much disk or memory over time.
If you run a webserver like Apache or Nginx, they by default enables request/error logs, in most cases you don't have to worry about it, but theses logs do grow over time. If you do not cleaning them up regularly, they could take over much of the disk space and cause issue with operating system or other software.
Rotate logs regularly
Separate data partition
Even with logrotate, we may still have significant disk usage by logs or other data files. One common problem with cloud machines is the root partitions are small and only have a few GBs of free space. Once the free space is used, the operating system may have problem running basic services. So if you anticipate more than a few GBs of disk usage, it is always a good idea to mount an extra partition dedicated for data usage (and leave enough free space in the root partition for operating system).
You may also consult your software manual to move log files to separate data partition, E.g. for Apache web server, you can update the httpd.conf entries to tell it create the log files in different paths.
Memory Usage
Besides disk space, memory usage can also grow over time and cause system crashes. Most people would reserve enough intial memory for their server and software to start running. However, you may need more memory over time, especially if you server deal with accumulative data (e.g., load more data into memory when user data grows after a few months).
It is important to examine your data/memory usage for some time to get a good sense of how much it would grow over time, and reserve enough memory to deal with the worse case or have a scaling strategy.
There are more things to consider when building a server that supposed to run 24x7 for a long time, but start with things above will give you a good basis.