Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

run python / xrandr in window not as cronjob #856

Open
rohrbachger opened this issue Oct 10, 2024 · 1 comment
Open

run python / xrandr in window not as cronjob #856

rohrbachger opened this issue Oct 10, 2024 · 1 comment

Comments

@rohrbachger
Copy link
Contributor

As we have some thinstations running I would like to get the serial number and model from the screens,
and write that to an inventory database. We have about 100 thinstations with dual screen. ( View Horizon)

With python pedid this is no big deal, doing it from terminal.

But I did not figured out to run in the scheduled task or service.
Technical I did but with a test I figured out that xrandr did not create output if i is running
as a crontab job.
It has only to run once per day or restart.
Any suggestions and ideas? In pedid the xrandr output is parsed.

@Doncuppjr
Copy link
Contributor

Doncuppjr commented Oct 10, 2024

Perhaps as a cronjob, the DISPLAY variable is not available.

You could make a script, create a service file and a timer file for that service.

  1. Creating the Service File
    Create a systemd service file (example.service) that specifies what command or script you want to run. Here’s a basic template:

[Unit]
Description=Daily Task Service

[Service]
Type=oneshot
ExecStart=/path/to/your/script.sh

[Install]
WantedBy=multi-user.target

Replace /path/to/your/script.sh with the path to your script or command.

  1. Creating the Timer File
    Next, create a systemd timer file (example.timer) to schedule the service. Here’s how you can set it up to run once a day:

[Unit]
Description=Runs the Daily Task Service once a day

[Timer]
OnCalendar=daily
Persistent=true

[Install]
WantedBy=timers.target

This timer activates the service once a day at midnight. The Persistent=true option ensures that the task will be executed once the system is up if it was down at the scheduled time.

  1. Finally, in some finalize script, you will want to enable the timer.

systemctl enable example.timer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants