Schedule a task using systemd services and timer
Project description
SchedulerX
Authors
Installation
pip install SchedulerX
Setting ROOT_PASSWORD to env variable
Handling systemd needs root privilege so this why we export it. so, you need to run this command and change the <your-root-password> with your root password
export ROOT_PASSWORD="<your-root-password>"
Usage/Examples
For simple usage, you have to know how to set onCalendar in systemd
from schedulerx import SimpleScheduler
scheduler = SimpleScheduler(
title="shutdown at midnight",
command="shutdown now",
on_calendar=@daily
)
scheduler.schedule()
for more complex usage you have to know about how we create a timer and a service in systemd
And then you can use ServiceTimerManager
from schedulerx import ServiceTimerManager
service_timer = ServiceTimerManager(
service_filename="shutdown.service",
service_description="shutdown at midnight",
command="shutdown now",
timer_filename="shutdown.timer",
timer_description="shutdown at midnight timer",
on_calendar="@daily",
)
service_timer.schedule()
License
Class Diagram of SchedulerX
classDiagram
class PasswordHelper{
+get_root_password()
}
class CommandHandler{
+run_shell_command_with_input(command: string, password: string): string
+run_shell_command_as_root(command: string)
}
class PermissionManager{
-command_handler: CommandHandler
+change_path_permissions(path: string, permissions: string)
+is_writable(path: string): boolean
}
class FileManager{
filename: string
overwrite: string = False
-permission_manager: PermissionManager
<<property>> +file_full_path(): string
-save_origin_systemd_writable_permission()
+create_file(content: string)
+is_file_exist(): boolean
+check_permissions()
}
class ServiceManager{
+filename: string
+command: string
+description: string = ""
+overwrite: boolean = False
+create_service_file()
-get_service_text(): string
}
class TimerManager{
+filename: string
+description: string = ""
+on_calendar: string
+service_manager: ServiceManager
-file_manager: FileManager
-command_handler: CommandHandler
-get_timer_text(): string
+create_timer()
+start_timer()
}
class ServiceTimerManager{
+service_filename: string
+service_description: string = ""
+command: string
+timer_filename: string
+timer_description: string = ""
+on_calendar: string
+overwrite: boolean = False
-service_manager: ServiceManager
-timer_manager: TimerManager
+schedule()
-create_service()
-create_timer()
}
class SimpleSchedule{
+title: string
+command: string
+on_calendar: string
+overwrite: boolean = False
+schedule()
}
CommandHandler --> PasswordHelper
PermissionManager --> CommandHandler
FileManager --> PermissionManager
ServiceManager --> FileManager
TimerManager --> ServiceManager
TimerManager --> FileManager
TimerManager --> CommandHandler
ServiceTimerManager --> ServiceManager
ServiceTimerManager --> TimerManager
SimpleSchedule --> ServiceTimerManager
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file SchedulerX-0.0.2.tar.gz.
File metadata
- Download URL: SchedulerX-0.0.2.tar.gz
- Upload date:
- Size: 7.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.0rc1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
606b48dcd5c784b6f27de01dec9af15fd062e74a8b1e2f35ee8b3bf8f734085e
|
|
| MD5 |
dd82293fcba1ad1cc5b58266344c03f3
|
|
| BLAKE2b-256 |
9a198574141058a91d912c28bb5adf84615a213e8f7d2fa0799301100f2d0f20
|
File details
Details for the file SchedulerX-0.0.2-py3-none-any.whl.
File metadata
- Download URL: SchedulerX-0.0.2-py3-none-any.whl
- Upload date:
- Size: 9.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.0rc1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a82d1a3b7d607561beeb41836a82d1595ca685fb69446d2646183603e1f6bb45
|
|
| MD5 |
aab5273c9cc6545bad2a7d024a086c1f
|
|
| BLAKE2b-256 |
22fe80d0b478cf209f93fa2774744db2e43f225355dc3c842a04f2ec8494bb20
|