What kind of scripts is Crontab capable of running?

About writing shell scripts and making the most of your shell
Forum rules
Topics in this forum are automatically closed 6 months after creation.
Locked
Scysograph
Level 1
Level 1
Posts: 23
Joined: Sun Nov 01, 2020 3:47 pm

What kind of scripts is Crontab capable of running?

Post by Scysograph »

I have a very simple script to use as a test before I get more advanced with it, but it just doesn't seem to run even though it works fine from the terminal.

I just put this in my crontab

Code: Select all

@reboot /home/user/script
and this is the script.

Code: Select all

redshift -O 3000
The only reason I can think of that it isn't working is that it tries to run it before the X server is initialized.

This wouldn't be such problem for me if I could use shortcuts before I logged in, but now that I think about it users could have different shortcuts for the same bindings.
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
1000
Level 6
Level 6
Posts: 1039
Joined: Wed Jul 29, 2020 2:14 am

Re: What kind of scripts is Crontab capable of running?

Post by 1000 »

Cron handles all scripts
The problem is different.

1. From user or from root account.
You can add a cron list as a user.
But people usually add the cron list as root.
Difference:
If you add as root / administrator the script will run under the root account
If you add from a user account it will run under the user account.

If you want add cron job from root. You can try run script from other user.

Code: Select all

sudo -u USER_NAME script
2. Launch rights.
Cron has fewer and fewer rights.
Sometimes You have to bring him back.
The script will run. But it can't start windows / applications with windows.
Workaround / Example:

Code: Select all

notify-send 'Boss !!' 'This working'
This will working from terminal. For Cron you need add something.
Example: export DISPLAY=:0.0 && export XAUTHORITY=/home/USER_NAME/.Xauthority && script
viewtopic.php?f=49&t=331950&p=1900455&h ... b#p1900455

After create Cron task, you can check all Cron tasks
viewtopic.php?p=1973411#p1973411

3. Delay
it tries to run it before the X server is initialized.
It can be true.
You can add delay for task. For example 5 seconds. ( You can add more seconds )

Code: Select all

@reboot  sleep 5s && /home/user/script
Locked

Return to “Scripts & Bash”