NI Linux Real-Time Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Cron.daily script not working

I have a script in the /etc/cron.daily directory which should call another script in the /home/lvuser directory. I know that run-parts does not like extensions therefore my script in the /etc/cron.daily looks like this...

 

 

-rwx-r--r-- 1 admin administ database_backup

 

 

The script contents are...

 

/bin/bash /home/lvuser/database_backup.sh

 

 

The database_backup.sh runs just fine when directly calling ti from the commandline and run-parts shows that the script is called, but the script in /home/lvuser/ doesn't actually execute.

 

Any ideas?

 

EDIT: nevermind. It was the --test option. That test the call, but does not actually run the script.

Doug Ferguson

www.southerndaqsolutions.com
0 Kudos
Message 1 of 5
(1,662 Views)

I thought I would update this since I have found this topic confusing. My cRIO uses the 18.0 feeds and I have the following cron related files and folders:

/etc/cron.d
/etc/cron.daily
/etc/cron.hourly
/etc/cron.monthly
/etc/cron.weekly
crontab

 

Jobs in the /etc/cron.daily do not execute and I believe this is due to the cron.daily being commented out in the crontab file.

 

The contents of my crontab are as follows:

# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.

SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

#  m  h  dom mon dow user   command
#  1  *     * * *    root        cd / && run-parts /etc/cron.hourly
# 30  7     * * *    root        cd / && run-parts /etc/cron.daily
# 42  7     * * 7    root        cd / && run-parts /etc/cron.weekly
# 55  7     1 * *    root        cd / && run-parts /etc/cron.monthly

 

My /etc/cron.d look like this:

admin@NI-cRIO-01E017D7:/etc/cron.d# ls -l
-rw-r--r--   1  admin  administ      57  Sep 16 2021 logrorate

the contents of lograte is the standard cron formatting and looks like this...

*/5 * * * * root /usr/sbin/logrotate /etc/logrotate.conf

 

Simply putting a shell script in the cron.daily folder does not work.

Doug Ferguson

www.southerndaqsolutions.com
0 Kudos
Message 2 of 5
(1,290 Views)

@DougFerguson wrote:

Jobs in the /etc/cron.daily do not execute and I believe this is due to the cron.daily being commented out in the crontab file.

That's definitely one reason for the cron.daily items not running. 🙂

 

I didn't quite understand from your post if that action fixed your issue or not. If not, you could try making the files in /etc/cron.daily executable for the owner. I believe run-parts command requires those scripts to be so, at least in Debian OS.

 

0 Kudos
Message 3 of 5
(1,275 Views)

I was able to get the intended function working by just adding the desired shell script to the cron.d.

 

For now, I am not using the cron.daily. The confusion on my part was that, in effect, there was 2 ways to run a cron job. You can use either the cron.d OR the cron.daily (as an example). BUT to use the cron.daily (as an example) you need to edit the /etc/crontab. It appears that cron.d runs without any additional enabling.

Doug Ferguson

www.southerndaqsolutions.com
0 Kudos
Message 4 of 5
(1,260 Views)

@DougFerguson wrote:

I was able to get the intended function working by just adding the desired shell script to the cron.d.


👍

 


@DougFerguson wrote:

...in effect, there was 2 ways to run a cron job.


 

For posterity, a third way exists (excerpt from cron manual page):

"cron searches its spool area (/var/spool/cron/crontabs) for crontab files (which are named after accounts in
/etc/passwd); crontabs found are loaded into memory. Note that crontabs in this directory should not be accessed
directly - the crontab command should be used to access and update them."

 

 

0 Kudos
Message 5 of 5
(1,253 Views)