LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 12-08-2015, 11:50 AM   #1
Sum1
Member
 
Registered: Jul 2007
Distribution: Fedora, CentOS, and would like to get back to Gentoo
Posts: 332

Rep: Reputation: 30
Cronjobs Don't Run ?


Feeling a bit foolish for not being able to troubleshoot this, but here goes:

I've created a cronjob on Fedora 23 using command - ~$crontab -e

Crontab -l reports - ~$20 20 * * * user /home/user/bash-script
At 20 minutes of hour 20, user executes the following bash script /home/user/bash-script > /tmp/user-cron.log.

The cronjob doesn't run.
Crontab log in /var/log is empty.
User-cron.log in /tmp is empty.

"bash-script" is definitely executable.
No super-spy stuff in it -- it's simply making a tarball of directory:

#/bin/bash
cd /home/user && setfacl -R -b /home/user/stuff && tar -cJvf stuff-$(date +%Y-%m-%d-%H-%M-%S).tar.xz /home/user/stuff

I've stopped and restarted the crond daemon --

systemctl stop crond.service
systemctl start crond.service

Cron daemon is currently running --

9953 ? 00:00:00 crond

When I run bash-script manually from terminal it does exactly what it's supposed to do without errors.

I can't see what I'm missing to get the cronjob to work.

Thanks for your help.
 
Old 12-08-2015, 11:56 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,850

Rep: Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309
~$ is part of the cronjob, or ??? (that should not be)
in crontab do the following:
Code:
20 20 * * * user /home/user/bash-script >/tmp/log 2>&1
and check the log
 
1 members found this post helpful.
Old 12-08-2015, 12:03 PM   #3
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
please show us the output of crontab -l.
which setfacl are you trying to use ?
try modifying the script to look like this:
Code:
#/bin/bash
/usr/bin/echo start script
cd /home/user && setfacl -R -b /home/user/stuff && tar -cJvf stuff-$(date +Y-%m-%d-%H-%M-%S).tar.xz /home/user/stuff
/usr/bin/echo end script
 
Old 12-08-2015, 12:13 PM   #4
Sum1
Member
 
Registered: Jul 2007
Distribution: Fedora, CentOS, and would like to get back to Gentoo
Posts: 332

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by pan64 View Post
~$ is part of the cronjob, or ???
no - ~$
it was only meant to imitate the terminal prompt.
 
Old 12-08-2015, 12:17 PM   #5
Sum1
Member
 
Registered: Jul 2007
Distribution: Fedora, CentOS, and would like to get back to Gentoo
Posts: 332

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by schneidz View Post
please show us the output of crontab -l.
[user@userland]$ crontab -l
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root

# For details see man 4 crontabs

# Example of job definition:
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * user-name command to be executed

20 20 * * * user /home/user/bash-script > /tmp/user-cron.log
 
Old 12-08-2015, 12:19 PM   #6
Sum1
Member
 
Registered: Jul 2007
Distribution: Fedora, CentOS, and would like to get back to Gentoo
Posts: 332

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by schneidz View Post
which setfacl are you trying to use ?
NAME
setfacl - set file access control lists

SYNOPSIS
setfacl [-bkndRLPvh] [{-m|-x} acl_spec] [{-M|-X} acl_file] file ...

setfacl --restore=file

DESCRIPTION
This utility sets Access Control Lists (ACLs) of files and directories. On the command line, a sequence of commands is followed by a sequence of files (which in turn can be fol‐
lowed by another sequence of commands, ...).
 
Old 12-08-2015, 12:21 PM   #7
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
Code:
[schneidz@hyper lq]$ which setfacl
/usr/bin/setfacl
also which date are you trying to use ?

Last edited by schneidz; 12-08-2015 at 12:24 PM.
 
Old 12-08-2015, 12:28 PM   #8
Sum1
Member
 
Registered: Jul 2007
Distribution: Fedora, CentOS, and would like to get back to Gentoo
Posts: 332

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by schneidz View Post
Code:
#/bin/bash
/usr/bin/echo start script
cd /home/user && setfacl -R -b /home/user/stuff && tar -cJvf stuff-$(date +Y-%m-%d-%H-%M-%S).tar.xz /home/user/stuff
/usr/bin/echo end script
modified the bash script as you suggested and reset the time for the cronjob.
should know whether it works in approx 3 - 4 mins.

thanks for your help and suggestions.
 
Old 12-08-2015, 12:34 PM   #9
Sum1
Member
 
Registered: Jul 2007
Distribution: Fedora, CentOS, and would like to get back to Gentoo
Posts: 332

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by schneidz View Post
Code:
[schneidz@hyper lq]$ which setfacl
/usr/bin/setfacl
also which date are you trying to use ?
/usr/bin/date


\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

crud --- the changes in previous post did not work.
cronjob did not execute at 29 minutes past 18th hour as reset in crontab.
 
Old 12-08-2015, 12:36 PM   #10
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
i tried this and ended up with an empty file:
Code:
[schneidz@hyper lq]$ crontab -l
* * * * * schneidz /usr/bin/echo "hello world" > /home/schneidz/lq/hw.txt
i changed it to this and file has hello world in it:
Code:
[schneidz@hyper lq]$ crontab -l
* * * * * /usr/bin/echo "hello world" > /home/schneidz/lq/hw.txt
 
1 members found this post helpful.
Old 12-08-2015, 01:09 PM   #11
Sum1
Member
 
Registered: Jul 2007
Distribution: Fedora, CentOS, and would like to get back to Gentoo
Posts: 332

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by schneidz View Post
Code:
[schneidz@hyper lq]$ crontab -l
* * * * * /usr/bin/echo "hello world" > /home/schneidz/lq/hw.txt
G-E-N-I-U-S ! !
Cronjob started moments ago.
The crontab entry functions WITHOUT indicating the "user" executing the command.

Nice deduction.
Thank you, Schneidz.
 
Old 12-08-2015, 09:08 PM   #12
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
As per https://serverfault.com/questions/35...-specific-user
Quote:
Only /etc/crontab and the files in /etc/cron.d/ have a username field.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
XaoS don't run atomix600 Slackware 3 05-04-2011 02:48 PM
don't know how to run smartmontools newbiesforever Linux - Software 4 12-03-2008 01:18 PM
some cronjobs don't work xpucto Linux - Newbie 5 05-05-2008 06:25 AM
wwwrun user cronjobs don't run tristaoh SUSE / openSUSE 1 06-15-2007 05:13 PM
I've run out of space and don't know what to do. BongFish Linux - General 13 10-21-2003 11:40 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 09:50 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration