87

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 ...


34

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 the ...


31

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 ...


29

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 ...


28

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 ...


27

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' /...


26

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 ...


22

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 ...


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, ...


17

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.


16

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


14

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 ...


12

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, ...


11

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

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

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 ...


10

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


10

The shutdown command has already an embedded scheduler so you don't need a cron job for it to run at the specified time. In Linux as everywhere else, it's better to stick to the KISS principle (Keep It Short and Simple). shutdown -h 22:00 will work fine, no need to run it in the background. Add the command at the end of /etc/rc.local (or /etc/rc.d/rc....


10

You could use a couple of cron jobs: # ┌───────────── min (0 - 59) # │ ┌────────────── hour (0 - 23) # │ │ ┌─────────────── day of month (1 - 31) # │ │ │ ┌──────────────── month (1 - 12) # │ │ │ │ ┌───────────────── day of week (0 - 6) # │ │ │ │ │ # │ │ │ │ │ * * * * * systemctl start $SERVICE.service * * * * * systemctl stop $SERVICE....


10

From crontab(5): @hourly: Run once an hour, ie. "0 * * * *". So it's strictly the same. To run a job at a varying point in the hour (or multiple jobs, to spread the load) you can sleep for a random amount of time before starting the job: @hourly sleep $((RANDOM / 10)); dowhatever This sleeps for up to 3276 seconds (nearly an hour), then runs the ...


9

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 ...


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.


9

To stop a service A with a timer, you can create a service B of type oneshot that it will be in conflict with, then use a timer to start the service B. If a unit has a Conflicts= setting on another unit, starting the former will stop the latter and vice versa. (source) A.service: [Unit] Conflicts=B.service ... B.service: [Unit] Description=B service ...


9

The Linux timer interrupt handler doesn’t do all that much directly. For x86, you’ll find the default PIT/HPET timer interrupt handler in arch/x86/kernel/time.c: static irqreturn_t timer_interrupt(int irq, void *dev_id) { global_clock_event->event_handler(global_clock_event); return IRQ_HANDLED; } This calls the event handler for global clock ...


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

To list all crons for the given user. crontab -u username -l; To list all crons for all users Run it as a super user #!/bin/bash #List all cron jobs for all users for user in `cat /etc/passwd | cut -d":" -f1`; do crontab -l -u $user; done


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,...


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