Skip to main content
Share Your Experience: Take the 2024 Developer Survey
29 votes
Accepted

How to enable and use the BFQ scheduler?

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 ...
RomuloPBenedetti's user avatar
28 votes

What was the reason of the non-preemptivity of older Linux kernels?

In the context of the Linux kernel, when people talk about preemption they often refer to the kernel’s ability to interrupt itself — essentially, switch tasks while running kernel code. Allowing this ...
Stephen Kitt's user avatar
22 votes
Accepted

Does `at` run a command later if the computer is off at the specified time?

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 ...
dessert's user avatar
  • 1,687
19 votes

Check file is present and it is not empty

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 ...
the_velour_fog's user avatar
17 votes

Start/stop a systemd.service at specific times

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 ...
Radivarig's user avatar
  • 1,144
16 votes
Accepted

@hourly vs 0 * * * * - Cron - How to run jobs hourly, but at different times

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 ...
Stephen Kitt's user avatar
14 votes

Using and understanding systemd scheduling-related options in a desktop context

CPUScheduling{Policy|Priority} The link tells you that CPUSchedulingPriority should only be set for fifo or rr ("real-time") tasks. You do not want to force real-time scheduling on services. ...
sourcejedi's user avatar
  • 50.8k
12 votes

What was the reason of the non-preemptivity of older Linux kernels?

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....
peterh's user avatar
  • 9,786
12 votes
Accepted

How does the kernel scheduler know how to pre-empt a process?

"The kernel is not a process." This is pure terminology. (Terminology is important.) The kernel is not a process because by definition processes exist in userland. But the kernel does have threads. "...
AlexP's user avatar
  • 10.5k
12 votes
Accepted

Linux timer interrupt

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(...
Stephen Kitt's user avatar
10 votes

Run script every 30 min with systemd

The proper way is to use systemd-run you can schedule your job without the need to define your own unit. It allows you to schedule by a calendar or every period of time. Assuming MYSELF is your full ...
fcm's user avatar
  • 447
8 votes

Start/stop a systemd.service at specific times

There indeed is another way to stop a service after certain runtime configured in the .service file. RuntimeMaxSec=... You may not like the fact that the service is considered failed but that's a ...
Pavel Šimerda's user avatar
8 votes
Accepted

Understanding Linux Perf sched-switch and context-switches

I know this question is pretty old (Feb 16) but here a response in case it helps someone else. The problem is that you've entered the '-F 999' indicating that you want to sample the events at a ...
pat's user avatar
  • 96
8 votes

@hourly vs 0 * * * * - Cron - How to run jobs hourly, but at different times

@hourly is an exact synonym of 0 * * * * in crontab, there is no difference. @hourly is a special string representation for 0 * * * *. From man 5 crontab: string meaning ------ ------...
heemayl's user avatar
  • 56.5k
8 votes
Accepted

How to reschedule an at job to run earlier?

There are two possibilities: First, there is a method over on stackoverflow.com about this It does preserve the job number Second, using at to duplicate the job at a new time: at -c 9 | at now + 1 ...
Grant's user avatar
  • 96
8 votes
Accepted

How to recover deleted crontab

You can find your cron jobs from the log if once it has executed before. Check /var/log/cron. You do not have any recovery option other than third party recovery tools.
Muhammed Sherief's user avatar
8 votes

Understanding overhead cost of context switching

There are as many answers to this as there are operating system versions. No single answer covers everything. Basically, the cost of context switching is the cost of saving all of the cpu state ...
user10489's user avatar
  • 7,082
7 votes
Accepted

Repeat a task with the "at" command everyday at 6PM

man cron is your friend. For this, you might want to try something like: 0 18 * * * echo "ls -l" > /var/log/ls_log.log Add it to the crontab with crontab -e. Check the output of the command by ...
Ben's user avatar
  • 240
7 votes
Accepted

Does Linux 3.10 CFS have "timeslices"?

CFS doesn't have timeslices "in the way the previous scheduler had". In CFS a timeslice is basically the duration between consecutive switches to grant CPU execution time to the same thread. This ...
emmrk's user avatar
  • 369
7 votes

How to make a system suspend and resume on schedule?

I've created a shell script for this purpose using systemctl suspend and rtcwake commands to manage the power. When run, it'll work in a loop (15 minute cycles): checking what time and day of week ...
unfa's user avatar
  • 1,745
7 votes
Accepted

When will an interval cron execute the first time? (Ex: */3 days)

The crontab(5) man page use a wording that is pretty clear: Step values can be used in conjunction with ranges. Following a range with "/number" specifies skips of the number's value ...
Artur Meinild's user avatar
7 votes
Accepted

systemctl cannot access service file, Permission denied

Disable SElinux or set it to permissive. setenforce 0 This will disable it temporarily. Test again after disabling it, and see if this solves the issue.
Alex's user avatar
  • 1,968
6 votes

chrt(): "failed to set pid XXX's policy" on one machine, but not others

I had the same problem. The following command fixed it: sysctl -w kernel.sched_rt_runtime_us=-1 Source: https://lists.opensuse.org/opensuse-security/2011-04/msg00015.html
Forrest Voight's user avatar
6 votes
Accepted

How can I run two commands in succession from cron?

Files placed in /etc/cron.hourly, cron.daily and cron.monthly need to be executables. If you place a text file with a single line as shown in your question into that directory, it cannot be run at all ...
Warren Young's user avatar
  • 72.2k
6 votes
Accepted

What's the process scheduler in Linux?

In Linux, the process scheduler is a core part of the kernel. It doesn’t exist as a separate thread, or module, it’s implemented as a function, __schedule(). The job of the process scheduler is to ...
Stephen Kitt's user avatar
6 votes
Accepted

Are processes in square brackets scheduled in the same way as other processes?

Under Linux, ps and top handle information made available by the kernel in /proc, for each process, in a directory named after the pid. This includes two files, comm and cmdline; comm is the process’s ...
Stephen Kitt's user avatar
6 votes

What is the hardware which the linux kernel uses for timer interrupt

I suspect you were reading this or something very similar (https://elinux.org/Kernel_Timer_Systems): Timer Wheel, Jiffies and HZ (or, the way it was) The original kernel timer system (called the &...
Philip Couling's user avatar
6 votes

Schedule command to run at specific timestamp with systemd

systemd-run can schedule a command to be run at a specific time, as long as: the system is not powered down before that time, because it writes a transient timer & service file to /run, which is ...
Jeff Schaller's user avatar
  • 67.5k
6 votes
Accepted

Should I attempt to 'balance' my threads or does linux do this?

Linux: The Linux kernel have a great implementation for the matter and have many features/settings intended to manage the ressources for the running process (over CPU governors, sysctl or cgroup), in ...
intika's user avatar
  • 14.5k

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