Welcome, Guest. Please login or register.
Did you miss your activation email?

Author Topic: [EN] Problem with cron job, not working  (Read 3597 times)

Offline vilde

  • User
  • Posts: 708
[EN] Problem with cron job, not working
« on: 2018/01/02, 13:24:05 »
I have a script for changing wallpapers that I have run before with crontab. Did a new install yesterday and can't get crontab to work. I have searched for and not find any logs from crontab but it doesn't work, here is the output from crontab -l

Code: [Select]
bola@bola-pc:~$ crontab -l
# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(
#
# m h  dom mon dow   command
*/2 * * * *  /usr/bin/backdrop-randomizer R
#
bola@bola-pc:~$

I have tried with or without the last # in the crontab file

When I do the command/run the script manually the walpaper changed as it shall do.
Code: [Select]
backdrop-randomizer R

Edit :
Looks like cron is not working

Code: [Select]
bola@bola-pc:~$ systemctl status cron
● cron.service - Regular background program processing daemon
   Loaded: loaded (/lib/systemd/system/cron.service; disabled; vendor preset: en
   Active: inactive (dead)
     Docs: man:cron(

Now I have to find out how to start it ....
« Last Edit: 2018/01/02, 15:01:47 by vilde »

Offline unklarer

  • User
  • Posts: 816
Re: Problem with cron job, not working
« Reply #1 on: 2018/01/02, 15:19:53 »
Code: [Select]
# systemctl start cron.serviceand permanent
Code: [Select]
# systemctl enable cron.service

Offline vilde

  • User
  • Posts: 708
Re: Problem with cron job, not working
« Reply #2 on: 2018/01/02, 15:51:24 »
Code: [Select]
# systemctl start cron.serviceand permanent
Code: [Select]
# systemctl enable cron.service
I
Thank you unklarer, I did search internet for starting cron with systemd, didn't find it, I just found the maybe old way do do it and got it working?
Code: [Select]
# service cron start
# update-rc.d cron enable
+
so it's running now, shall I change to the systemd way?

As I understand there is a sytemd way instead of using cron to run a script  on scheduled times but I can't find anywhere how to do it, not that I understand anyway.

« Last Edit: 2018/01/02, 15:56:43 by vilde »

Offline unklarer

  • User
  • Posts: 816
Re: Problem with cron job, not working
« Reply #3 on: 2018/01/02, 17:15:27 »
Quote from: vilde
As I understand there is a sytemd way instead of using cron to run a script  on scheduled times but I can't find anywhere how to do it, not that I understand anyway.

There are many ways to Rome.   ;)


About a year ago I tried this in kde. It didn't work there. The package feh must be installed.

On the other hand, the same thing worked perfectly under Openbox / Fluxbox.


Maybe this will work, too:  feh.sh
Code: [Select]
#!/bin/sh
DIR=~/Images/Wallpapers
# temps de rotation des images en secondes
INT="600"

while true; do
    feh -q -r -z --bg-fill $DIR
    sleep $INT
done
exit 0

I haven't tried it.   :P

Offline vilde

  • User
  • Posts: 708
Re: Problem with cron job, not working
« Reply #4 on: 2018/01/02, 17:38:31 »
Quote from: vilde
As I understand there is a sytemd way instead of using cron to run a script  on scheduled times but I can't find anywhere how to do it, not that I understand anyway.

There are many ways to Rome.   ;)


About a year ago I tried this in kde. It didn't work there. The package feh must be installed.

On the other hand, the same thing worked perfectly under Openbox / Fluxbox.


Maybe this will work, too:  feh.sh
Code: [Select]
#!/bin/sh
DIR=~/Images/Wallpapers
# temps de rotation des images en secondes
INT="600"

while true; do
    feh -q -r -z --bg-fill $DIR
    sleep $INT
done
exit 0

I haven't tried it.   :P


The benefit with backdrop-randomizer is that it will "randomly cycles through wallpapers without repeating" The script first creates a random list of (in this case) wallpaper files in a specified mapp and then cycle through all of them before creating a new random list to start over again. It's made for XFCE from the beginning.

Offline melmarker

  • User
  • Posts: 2.799
    • g-com.eu
Re: Problem with cron job, not working
« Reply #5 on: 2018/01/02, 19:15:22 »
@vilde: fore the sake of mental health leave crontab alone and put a job into /etc/cron.d - thats all - the systemd way would be to use timers, should be easy, never used it :)
Those who would give up essential Liberty, to purchase a little temporary Safety, deserve neither Liberty nor Safety. (Benjamin Franklin, November 11, 1755)
Never attribute to malice that which can be adequately explained by stupidity. (Hanlons razor)

Offline vilde

  • User
  • Posts: 708
Re: Problem with cron job, not working
« Reply #6 on: 2018/01/02, 21:29:24 »
@vilde: fore the sake of mental health leave crontab alone and put a job into /etc/cron.d - thats all - the systemd way would be to use timers, should be easy, never used it :)


Hmm, I have used crontab the last year and more, maybe that's why I feel a little crazy, on the other hand Waylon sings:
 
Quote
I've always been crazy but it's kept me from going insane

Ok, so then I have to try to learn something new /etc/cron.d I will try fort the fun of it, or timings, I'll be back