You are not logged in.
Pages: 1
So I have made script that will minimize all windows 10 seconds after boot. It works when I run it in a terminal... but when I add it in the crontab it completely stops working....
My crontab looks like this,
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
* * * * * /home/chris/test.sh^new line at the end
And my script file is called test.sh
#! /bin/bash
sleep 10 && xdotool key super+dWhat is wrong with my configuration that i'm not seeing/getting?
Thank in advance for any help!!!
edit: also this is the output of systemctl status cronie.service
cronie.service - Periodic Command Scheduler
Loaded: loaded (/usr/lib/systemd/system/cronie.service; enabled; vendor preset: disabled)
Active: active (running) since Mon 2017-04-10 22:01:27 CDT; 43min ago
Main PID: 358 (crond)
Tasks: 1 (limit: 4915)
CGroup: /system.slice/cronie.service
└─358 /usr/bin/crond -n
Apr 10 22:42:11 ArchLinux CROND[5251]: (chris) CMDOUT (Error: Can't open display: (null))
Apr 10 22:42:11 ArchLinux CROND[5251]: (chris) CMDOUT (Failed creating new xdo instance)
Apr 10 22:43:01 ArchLinux crond[5294]: pam_unix(crond:session): session opened for user chris by (uid=0)
Apr 10 22:43:01 ArchLinux CROND[5295]: (chris) CMD (/home/chris/test.sh)
Apr 10 22:43:11 ArchLinux CROND[5294]: (chris) CMDOUT (Error: Can't open display: (null))
Apr 10 22:43:11 ArchLinux CROND[5294]: (chris) CMDOUT (Failed creating new xdo instance)
Apr 10 22:44:01 ArchLinux crond[5342]: pam_unix(crond:session): session opened for user chris by (uid=0)
Apr 10 22:44:01 ArchLinux CROND[5343]: (chris) CMD (/home/chris/test.sh)
Apr 10 22:44:11 ArchLinux CROND[5342]: (chris) CMDOUT (Error: Can't open display: (null))
Apr 10 22:44:11 ArchLinux CROND[5342]: (chris) CMDOUT (Failed creating new xdo instance)Last edited by chris190 (2017-04-11 04:05:21)
Offline
The first line of the error message, cron runs in a limited environment and knows nothing about DISPLAY.
Use a systemd timer and a user service.
Also, use code tags when pasting to the boards: https://wiki.archlinux.org/index.php/Co … s_and_code
Offline
@reboot starts cron script as soon as cron starts on reboot, so your window-manager may not have started yet.
To tell cron about display use something like this
@reboot env DISPLAY=:0 <yourscript>However still cron may start your script before your window-manager has started.
It would be better to add this script to your window-manager/DE's startup file or start it with systemd as suggested by Jasonwryan.
Last edited by Docbroke (2017-04-11 04:07:42)
Arch is home!
https://github.com/Docbroke
Offline
The first line of the error message, cron runs in a limited environment and knows nothing about DISPLAY.
Use a systemd timer and a user service.
Also, use code tags when pasting to the boards: https://wiki.archlinux.org/index.php/Co … s_and_code
Okay so I have made a minimize.timer and minimize.service in the /etc/systemd/system path
minimize.timer
[Unit]
Description=Minimize on startup
[Timer]
OnBootSec=10
Unit=minimize.service
[Install]
WantedBy=timers.targetminimize.service
[Unit]
Description=MinimizeAtBoot
[Service]
Type=oneshot
ExecStart=xdotool key super+d & DISPLAY=:0.0is that all correct?
And if so, then I just have to systemctl start and enable it right?
Last edited by chris190 (2017-04-11 04:34:24)
Offline
No. There is an env variable you use in the service file. Also, you want a --user not a system service. See the wiki page for details.
Offline
No. There is an env variable you use in the service file. Also, you want a --user not a system service. See the wiki page for details.
Okay after looking over the wiki/other tutorials for a while and i'm stumped here,
I have made a /usr/lib/systemd/minimize.service file
[Unit]
Description=MinimizeAtBoot
[Service]
Type=simple
ExecStart=/home/chris/test.shThen I made a /usr/lib/systemd/minimize.timer file
[Unit]
Description=Minimize on startup
[Timer]
OnBootSec=20
Unit=minimize.service
[Install]
WantedBy=timers.targetThen I ran systemctl --user enable minimize.timer
It works when I run systemctl --user start minimize.service, but the timer does not work on reboot.
I know im messing up somewhere, do I need to enable minimize.service too? or instead of simple run as oneshot? or some other command entirely?
edit: thanks for the help btw! its been really helpful so far ![]()
Last edited by chris190 (2017-04-11 06:30:22)
Offline
Offline
Pages: 1