Is it possible to set some sort of script that automaticly turns off the computer at certan time, for example at 10pm. I am running Ubuntu 18.04
Yes. The shutdown command allows for a delayed action.
shutdown -h 22:00
shuts the system down at 22:00 IF the system is running.
shutdown -r +1440
will shutdown in 24 hours (1440/60=24) so tomorrow at the current time.
If you want more elaborate methodes install at. That allows things like "at sunday", or "next week", "now + 120 min" and so on.
These commands need to be repeated every time you want this. Follow pilot6's answer to add a command to cron. If you use commands make sure to use absolute paths.
For example you could use a crontab: enter
sudo crontab -e (this opens the crontab file for the root user)
At the end on a new line you enter the following(it will shutdown the computer at 22PM):
0 22 * * * shutdown -P now >/dev/null 2>&1
This will shutdown The Syntax is:
* * * * * COMMAND
Beforte the command there are 5 thins to give:
1. Minute, 2. Hour, 3. Day of Month, 4. Month, 5. Day of Week.
All have to be true. If you put a star it accepts every value there. So you could also say execute a command at 7 AM, if it is a Friday the 13th:
0 7 13 * 5 /alert.sh