Cron jobs not executing

All Gurus once were Newbies
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Please stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions prefer the other forums within the support section.
Before you post please read how to get help
Post Reply
brvcf
Level 1
Level 1
Posts: 46
Joined: Fri Sep 08, 2017 10:44 pm

Cron jobs not executing

Post by brvcf »

I installed LuckyBackup. To test it I created a couple of directories with a few files and configured the program to bck them up to a flash drive. When I ran the backup manually it worked fine.

Then I changed some of the directory content and ran it again. My changes were reflected on the backup drive.

Then I went to the scheduler and scheduled it to run about 3 minutes later. I made a few changes to the directories and waited until after the scheduled run, and found nothing changed on the backup drive.

Tried a few variations of this with no luck.

I checked crontab using crontab -l

The job was there:

Code: Select all

20 16 * * *	env DISPLAY=:0 /usr/bin/luckybackup --silent --skip-critical /home/owner/.luckyBackup/profiles/default.profile > /home/owner/.luckyBackup/logs/default-LastCronLog.log 2>&1
I copied the command:

Code: Select all

/usr/bin/luckybackup --silent --skip-critical /home/owner/.luckyBackup/profiles/default.profile > /home/owner/.luckyBackup/logs/default-LastCronLog.log 2>&1
pasted it in to terminal and it ran fine.

I ran the command

Code: Select all

date +%T >>/home/owner/timefile.txt
a few times and verified it adde entries to the file.

Then I added it as a scheduled kob using crontab -e as

Code: Select all

* * * * * date +%T >>/home/owner/timefile.txt
and checked timefile.txt but it did not change.

So I conclude that jobs in crontab are just not being executed.

pgrep cron returms a pid number indicating the service is running.

There is no /etc/cron.allow or /etc/cron.allowdeny files.

I tried adding to both user and root crontab.

I don’t really consider myself a “newbie” but have not played around with cron much and it just seems this should not be that hard. Better part of the day spent on this. Too much of a learning experience without actually learning how to fix it….
User avatar
Kadaitcha Man
Level 11
Level 11
Posts: 3603
Joined: Mon Aug 27, 2012 10:17 pm

Re: Cron jobs not executing

Post by Kadaitcha Man »

brvcf wrote:
Thu Apr 16, 2020 8:53 pm
Better part of the day spent on this. Too much of a learning experience without actually learning how to fix it….
There may be any number of reasons so more troubleshooting on your part may be necessary.

If you edited the cron jobs with any command other than crontab -e then you may have borked cron, so this may be useful in that case. It could be that the cron job has been assigned to an incorrect user. More likely though, if the command line works but not your cron job then the differences between the two should be suspected, in which case, dropping env DISPLAY=:0 is recommended.

http://luckybackup.sourceforge.net/manual.html#terminal
Coming to a thread near you: Lots of bragging about my AMD 5950X. Currently delayed due to high demand.
It's pronounced kad-eye-cha, not kada-itcha.
brvcf
Level 1
Level 1
Posts: 46
Joined: Fri Sep 08, 2017 10:44 pm

Re: Cron jobs not executing

Post by brvcf »

Nope. Only used crontab -e.

I deleted the entry for the luckybackup job.

Left

Code: Select all

* * * * * date +%T >>/home/owner/timefile.txt
Still doesn't run.
User avatar
Kadaitcha Man
Level 11
Level 11
Posts: 3603
Joined: Mon Aug 27, 2012 10:17 pm

Re: Cron jobs not executing

Post by Kadaitcha Man »

brvcf wrote:
Thu Apr 16, 2020 9:46 pm
Still doesn't run.
Try env > /tmp/env.txt

cron only exports an absolute minimum of the environment, so comparing the output from above to the environment in a shell may reveal, for example, a missing path. An option that will circumvent this problem, assuming it's the cause of the issue, is to put the command in bash script and cron the script rather than the command:

Code: Select all

#!/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/some.path/bin:/bin:/usr/games:/usr/local/games:/snap/bin
/usr/bin/luckybackup --silent --skip-critical /home/owner/.luckyBackup/profiles/default.profile > /home/owner/.luckyBackup/logs/default-LastCronLog.log 2>&1
I suggest that because I think that cron is executing the jobs but they are failing due to the commands not being found, which in turn is due to cron exporting a minimal environment.

If your machine isn't running 24x7x52, perhaps investigating anacron is a better option.
Coming to a thread near you: Lots of bragging about my AMD 5950X. Currently delayed due to high demand.
It's pronounced kad-eye-cha, not kada-itcha.
ajgringo619
Level 8
Level 8
Posts: 2120
Joined: Thu Mar 01, 2018 8:36 pm
Location: San Diego, California, USA

Re: Cron jobs not executing

Post by ajgringo619 »

What does journalctl -u cron and systemctl status cron show?
Mint 20 XFCE [kernel 5.4.0-54-generic]
Ryzen 7 2700X Eight-Core w/16 GB RAM
GTX 1070 w/8GB RAM [Folding]
GTX 1050Ti w/4GB RAM [Nvidia v455.38]
Image
brvcf
Level 1
Level 1
Posts: 46
Joined: Fri Sep 08, 2017 10:44 pm

Re: Cron jobs not executing

Post by brvcf »

Thing is, installing a simple backup program from the repository, it should just work.
Say what you will about WIndoze but the built-in Backup and File History functions are easy to configure and work out of the box.

Results of env. Definitely beyond my knowledge.

Code: Select all

XDG_VTNR=7
SSH_AGENT_PID=1323
XDG_SESSION_ID=c1
XDG_GREETER_DATA_DIR=/var/lib/lightdm-data/owner
CLUTTER_IM_MODULE=
QT_STYLE_OVERRIDE=gtk
SESSION=xfce
GLADE_PIXMAP_PATH=:
TERM=xterm-256color
VTE_VERSION=4205
XDG_MENU_PREFIX=xfce-
SHELL=/bin/bash
QT_LINUX_ACCESSIBILITY_ALWAYS_ON=1
WINDOWID=46137347
UPSTART_SESSION=unix:abstract=/com/ubuntu/upstart-session/1000/1144
GNOME_KEYRING_CONTROL=
GTK_MODULES=gail:atk-bridge
USER=owner
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:
CLUTTER_BACKEND=x11
QT_ACCESSIBILITY=1
XDG_SESSION_PATH=/org/freedesktop/DisplayManager/Session0
GLADE_MODULE_PATH=:
XDG_SEAT_PATH=/org/freedesktop/DisplayManager/Seat0
SSH_AUTH_SOCK=/tmp/ssh-RxM5ZuTjmvnb/agent.1322
DEFAULTS_PATH=/usr/share/gconf/xfce.default.path
SESSION_MANAGER=local/owner-GC660AA-ABA-SR5123WM:@/tmp/.ICE-unix/1305,unix/owner-GC660AA-ABA-SR5123WM:/tmp/.ICE-unix/1305
XDG_CONFIG_DIRS=/etc/xdg/xdg-xfce:/usr/share/upstart/xdg:/etc/xdg:/etc/xdg
DESKTOP_SESSION=xfce
PATH=/home/owner/bin:/home/owner/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
QT_IM_MODULE=
XDG_SESSION_TYPE=x11
PWD=/home/owner
JOB=dbus
XMODIFIERS=
GNOME_KEYRING_PID=
LANG=en_US.UTF-8
GDM_LANG=en_US
MANDATORY_PATH=/usr/share/gconf/xfce.mandatory.path
IM_CONFIG_PHASE=1
GDMSESSION=xfce
SESSIONTYPE=
SHLVL=1
HOME=/home/owner
XDG_SEAT=seat0
LANGUAGE=en_US
UPSTART_INSTANCE=
GTK_OVERLAY_SCROLLING=0
UPSTART_EVENTS=started xsession
XDG_SESSION_DESKTOP=xfce
LOGNAME=owner
DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-KzbtajzofI
XDG_DATA_DIRS=/home/owner/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share/:/usr/share/xfce:/usr/share/xfce4:/home/owner/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share:/usr/local/share:/usr/share:/usr/share
QT4_IM_MODULE=
LESSOPEN=| /usr/bin/lesspipe %s
INSTANCE=
UPSTART_JOB=startxfce4
XDG_RUNTIME_DIR=/run/user/1000
DISPLAY=:0.0
GLADE_CATALOG_PATH=:
XDG_CURRENT_DESKTOP=XFCE
GTK_IM_MODULE=
LESSCLOSE=/usr/bin/lesspipe %s %s
XAUTHORITY=/home/owner/.Xauthority
COLORTERM=xfce4-terminal
_=/usr/bin/env
brvcf
Level 1
Level 1
Posts: 46
Joined: Fri Sep 08, 2017 10:44 pm

Re: Cron jobs not executing

Post by brvcf »

ajgringo619 wrote:
Thu Apr 16, 2020 10:16 pm
What does journalctl -u cron and systemctl status cron show?
I put this problem aside for a while. In the meantime I updated the kernel from 4.13.0-43.48~16.04.1 to 4.13.0-45.50~16.04.1.
So today I looked at the output of those two commands and it looked like cron was running and there were no obvious errors.
but I had removed all the entries from my crontab because nothing was working.
So I thought I had better put something in.
So I put in * * * * * echo test >>/home/owner/testfile.txt and it worked.
So then I tried * * * * * date >>/home/owner/timefile.txt and it worked
So then I went back to what I previously tried * * * * * date +%T >>/home/owner/timefile.txt and it didn't work
The exact syntax from the terminal.
So then I added the path * * * * * /bin/date +%T >>/home/owner/timefile.txt and it worked.
Not sure why. Is there two "date" commands with different syntax?
In any case, even if I had made errors in my manual crontab entries the first time, the only reason I did any manual entries is because the LuckyBackup scheduling didn't work. I wouldn't expect a well-rated program installed from the Software Manager to have made an incorrect entry.
Just for fun, I tried LuckyBackup again. Schedule now works.
Soooo, I am going to conclude that the problem was somewhere in the previous kernel. I could boot with the previous kernel and see what happens but I have wasted enough time on this "learning experience."
Post Reply

Return to “Newbie Questions”