You are not logged in.

#1 2023-11-22 18:08:09

6Virtuoso9
Member
Registered: 2023-11-21
Posts: 3

Need help with cron

Hello,

I am trying to use crontab to set up night light to run at certain time. However, when I tried to test it, I couldn't get it running as expected. Here are the cron files that I tried to use:

Option 1: Tell cron to run xrandr command every minute:

 * * * * * xrandr --output DP-2 --gamma 1.0:0.88:0.76 --brightness 0.5 

Option 2: Tell cron to run script for every minute instead (by following an example from Arch wiki - cron https://wiki.archlinux.org/title/cron#R … lications)

 * * * * * /home/user_name/Documents/07.sh 

I tried both of  these but they do not seems to work. And yes, the 07.sh has the

 #!/bin/bash 

to make sure the script can communicate with terminal and it is an executable file (when I double click it does change the gamma and brightness as expected).

Would love to get some help here. Thanks!

Offline

#2 2023-11-22 21:25:54

Funny0facer
Member
From: Germany
Registered: 2022-12-03
Posts: 159

Re: Need help with cron

please post the complete files and also tell us in what file exactly, you put those lines. Did you put in in /etc/crontab? If yes, I am missing the user that is supposed to run the command.
Is your file executable? (chmod +x)

# m h dom mon dow user command

a valid cronfile could look like this:
cat /etc/cron.d/0hourly

# Run the hourly jobs
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
01 * * * * root run-parts /etc/cron.hourly

Offline

#3 2023-11-22 22:33:16

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,462
Website

Re: Need help with cron

And is there any reason you need to use cron rather than a systemd timer?


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#4 2023-11-27 04:59:33

6Virtuoso9
Member
Registered: 2023-11-21
Posts: 3

Re: Need help with cron

Trilby wrote:

And is there any reason you need to use cron rather than a systemd timer?

I was told to use cron as a way to automate that. But I will look into systemd timer as another option to deal with.

Offline

#5 2023-11-27 05:03:08

6Virtuoso9
Member
Registered: 2023-11-21
Posts: 3

Re: Need help with cron

Funny0facer wrote:

please post the complete files and also tell us in what file exactly, you put those lines. Did you put in in /etc/crontab? If yes, I am missing the user that is supposed to run the command.
Is your file executable? (chmod +x)

# m h dom mon dow user command

a valid cronfile could look like this:
cat /etc/cron.d/0hourly

# Run the hourly jobs
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
01 * * * * root run-parts /etc/cron.hourly

I think I missed some headers in the cron file. I will let you know when I modified that.

Offline

#6 2023-11-27 05:08:43

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,462
Website

Re: Need help with cron

6Virtuoso9 wrote:

I was told to use cron...

By whom?  Someone using a system that uses cron by default and not systemd?  That advice would not apply to archlinux.

You certainly can run cron on arch, and some people do.  But that's a deliberate choice because they have specific reasons (or perhaps just prejudices) to prefer it to systemd timers.

If you were not already using cron and added it just for this, then that's definitely the wrong approach.  A systemd timer would be the proper approach for an archlinux system.

Note that this would likely be a systemd --user timer.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#7 2023-11-27 08:26:22

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,056

Re: Need help with cron

https://archlinux.org/packages/extra/x86_64/redshift/ exists …

As for cron'ning xrandr, you'll have to export at least the DISPLAY

Offline

Board footer

Powered by FluxBB