73

You can do this directly from the shutdown command, see man shutdown: SYNOPSIS /sbin/shutdown [-akrhPHfFnc] [-t sec] time [warning message] [...] time When to shutdown. So, for example: shutdown -h 21:45 That will run shutdown -h at 21:45. For commands that don't offer this functionality, you can try one of: A. Using at The at daemon is ...


27

I use a simple script with at: #!/bin/bash # email reminder notes using at(1)... read -p "Time of message? [HH:MM] " time read -p "Date of message? [dd.mm.yy] " date read -p "Message body? " message at "$time" "$date" <<EOF echo "$message" | mailx -s "REMINDER" me@gmail.com EOF You could just as easily pipe the $message to notify-send or dzen if ...


25

One alternative is to not shutdown, but to hibernate or suspend the system and then automatically wake it up using rtcwake utility. For example rtcwake -s 3600 -m disk will immediately hibernate (suspend to disk) the system and resume it in 1 hour. Similarly sleep 600; rtcwake -s 60 -m mem will suspend to ram in 10 minutes from now, and then resume ...


25

In the context of the Linux kernel, when people talk about pre-emption they often refer to the kernel’s ability to interrupt itself — essentially, switch tasks while running kernel code. Allowing this to happen is quite complex, which is probably the main reason it took a long time for the kernel to be made pre-emptible. At first most kernel code couldn’t ...


23

The proportion of the processor time a particular process receives is determined by the relative difference in niceness between it and other runnable processes. The Linux Completely Fair Scheduler (CFS) calculates a weight based on the niceness. The weight is roughly equivalent to 1024 / (1.25 ^ nice_value). As the nice value decreases the weight increases ...


23

No you can't specify a date at the shutdown command but two alternatives exist: 1) The easiest is to use the at command. The following example will execute shutdown +5 at a specific time and day: echo "shutdown +5" | at 10:05am 2019-01-19 2) if you don't mind using you calculator and want to shutdown in say 24hours (24*60=1440 minutes) and you're ...


23

You need to create two files: one for service, other for timer with same name. example: /etc/systemd/system/test.service [Unit] Description=test job [Service] Type=oneshot ExecStart=/bin/bash /tmp/1.sh /etc/systemd/system/test.timer [Unit] Description=test [Timer] OnUnitActiveSec=10s OnBootSec=10s [Install] WantedBy=timers.target after that reload ...


20

I'm not in Ubuntu, but what I did in Fedora may help you. BFQ is a blk-mq (Multi-Queue Block IO Queueing Mechanism) scheduler, so you need to enable blk-mq at boot time, edit your /etc/default/grub file and add scsi_mod.use_blk_mq=1 to your GRUB_CMDLINE_LINUX, this is my grub file, as an example: GRUB_TIMEOUT=3 GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /...


20

at executes any command that should have been executed before when you wake up the computer, but may take a few minutes to do that. It doesn't even matter whether you gave it a specific date, as you can test easily: $ sudo date -s "2017-12-15 23:57:00" $ at 23:59 17-12-15 <<<'echo executed >at_test' job 1 at Fri Dec 15 23:59:00 2017 # suspend, ...


18

Question 1 It is possible for an user to use real time priority for a process as well. This configuration could be set from /etc/security/limits.conf file. I see the below contents in that file. # /etc/security/limits.conf # #Each line describes a limit for a user in the form: # #<domain> <type> <item> <value> If we check ...


16

In the case of your particular script, neither Myscript nor command D will ever be executed. You've defined a function C, but you aren't calling it. The order of execution is: command B runs to completion. command E runs to completion. If you were to call C, it would run Myscript to completion, then run command D to completion. Everything you invoke in a ...


16

Check out the Wake-on-LAN (WoL) feature. Arch Linux has nice documentation on using it, and do not worry; it is Linux general. In Ubuntu you have the wakeonlan package to send magic packets to your machine. Here is Ubuntu documentation on using WoL. So to turn your machine automatically, you will have to use another machine that will turn it on with WoL.


15

That's the way GNU/Linux and other multitasking systems work, they share the processor among the running processes, dot won't have 99%, but 100% during 99% of the time. Each process dominates the processor for a certain period of time. This is handled by schedulers (linux has several schedulers, some just employ the usual strategy, some try to give more ...


15

From man bash | less '+/^\s*CONDITIONAL' -s file True if file exists and has a size greater than zero. To get the script to run at a pre-defined time, put your code into an executable scipt and load it into a cronjob. I suspect you possibly could put your command into a one liner and load it into a crobtab? ( I would be interested to know if anyone ...


13

If a task is blocked, it waits for resources to become available again. In your case there was propably either a IO-problem or a contention in the disk-area. Or your system-load was so high that there was not enough CPU-power available to finish the job in time. I have seen this error from cron, if it tries to start a job in a very busy time.


12

Cron is used to schedule a job to run repeatedly. What you want is at, which schedules a job to run one-time. For your example you can write: at midnight This will bring up an interactive prompt where you can enter /tmp/script.sh followed by Ctrl+D.


12

You can suspend or hibernate your system and then automatically wake it up with rtcwake command. For example to suspend (to ram) and resume in 60 seconds do rtcwake -s 60 -m mem To hibernate (suspend to disk) in one hour from now and resume in two hours: sleep 3600; rtcwake -s 3600 -m disk You can also wakeup the system at given time with -t option which ...


11

Preemptive kernel only means that there is no Big Kernel Lock. Linux had preemptive multi-tasking (i.e. user code was preemptible) since its first moment (as far I know, the very-very first Linux 0.0.1 uploaded by Linus to the funet ftp server was already preemptive multitask). If you executed, for example, multiple compression or compilation processes, ...


10

qBittorrent does have scheduling! However, it may or may not be sufficiently sophisticated for your needs. Scheduling Global Changes in Limits for Specific Days/Times Click Tools > Options.... Click the Speed tab on the left. At the bottom of the window you'll see options to set the upload and download rate limits for Alternative Global Rate Limits. Then ...


10

Why not use watch to update qstat at a regular interval? watch --interval=0.5 qstat will refresh the terminal with the output of qstat every 0.5 seconds. It doesn't quite satisfy your request of not running qstat repeatedly, but it's not manual at all.


10

Here is another option without using your timer. If timing is not terribly critical and and script isn't long running it will be fine for simple things. [Unit] Description=Run foo [Service] User=%I Restart=always RestartSec=1800s ExecStart=/bin/bash /home/user/script.sh


9

You could use the command 'at' at now +4 hours -f commandfile Or at now +$((($RANDOM % 10)+2)) hours -f commandfile


9

You should be able to do this with a mains timer between the mains outlet and the power supply. Shut down the Raspberry at 4 A.M using a cron job, then set the timer to cut the mains a bit later and to restore power at 5 A.M.


8

In echo 'one' > /tmp/a The shell does an open(O_WRONLY) on the pipe and then spawns echo which then does the write("one\n"). The open will block until some other process opens the pipe in RD_ONLY or RD_WR though. And so will the open from your echo two. So at the moment you do more /tmp/a you've got two processes ready to fire that have not opened ...


8

This is 100% normal with respect to threading on any and all operating systems. The documentation for your thread library, any examples and tutorials you may find, etc. are likely to make a point of this as it is often confusing to people when they are learning the ropes of threading. Threads are by default (and by definition) not synchronized. This means ...


8

I found this Q&A over on StackOverflow titled: How does cron internally schedule jobs?. excerpt from that post & the wikipedia article on cron The algorithm used by this cron is as follows: 1. On start-up, look for a file named .crontab in the home directories of all account holders. 2. For each crontab file found, determine the next time in ...


8

Depending on your Linux distribution and the kind of installation (minimal, desktop-centric, etc.) at (and atd the at job scheduler daemon) is installed by default or not. To verify it you can issue commands like: $ which at /usr/bin/at $ which atd /usr/bin/atd $ yum whatprovides atd # to get the package name $ yum info pkg-name # to see if it is ...


8

You can get it to turn off whenever you like with halt or shutdown now or whatever you prefer; schedule that with cron or a custom sleeping background process. In addition to the real time wakeup implemented by normal PC hardware (which the pi isn't) and usable via rtcwake, there is wake-on-LAN. Unfortunately, neither of those will work on the raspberry pi,...


7

The current Linux task scheduler is called Completely Fair Scheduler (CFS). You should have a look at http://people.redhat.com/mingo/cfs-scheduler/sched-design-CFS.txt for more details. The design is quite complex and in my view not suitable for RTOS. A common technique in realtime systems is rate-monotonic scheduling, because it has strong guarantees if ...


7

There's a standard batch command that does more or less what you're after. More precisely, batch executes the jobs when the system load is not too high, one at a time (so it doesn't do any parallelization). The batch command is part of the at package. echo 'command1 --foo=bar' | batch echo 'command2 "$(wibble)"' | batch at -q b -l # on ...


Only top voted, non community-wiki answers of a minimum length are eligible