Solved

cronjobs not working via user - but works fine with root

Posted on 2013-10-29
12
317 Views
Last Modified: 2014-01-28
Hi,

Please help as cron jobs runs fine from root.

but when running from a specific users its not running.

Please help


no error and output or message coming.
0
Comment
Question by:apunkabollywood
  • 5
  • 3
  • 2
  • +2
12 Comments
 
LVL 6

Expert Comment

by:Kailash Aghera
ID: 39608456
What is the ownership of the file which you are executing via cron? Make sure that it is user:user and the permission of the file is 755.
0
 

Author Comment

by:apunkabollywood
ID: 39608658
Hi,

its  user:group  and 777
0
 

Author Comment

by:apunkabollywood
ID: 39608665
The problem when i am logging with user and scheduling any cronjob even echo command its not working
0
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 
LVL 13

Assisted Solution

by:Daniel Helgenberger
Daniel Helgenberger earned 500 total points
ID: 39609156
This is most commonly a run environment issue.
First, check whatever cron really runs your user's crontab entries:
grep CRON /var/log/syslog

Open in new window

If they are run, you most commonly have permissions/or $PATH errors. Please debug this with output redirection; like this example crontab entry:
crontab -l
0 0 * * * ~/myscript > ~/myscript.log 2>&1

Open in new window

Please note, commands like echo will never work (as expected to the console) with cron; the output is redirected to mails by default.
0
 

Author Comment

by:apunkabollywood
ID: 39609312
I have checked secure logs and found this :
 pam_unix(crond:account): account myuser has expired (failed to change password)
 how to fix
0
 
LVL 13

Expert Comment

by:Daniel Helgenberger
ID: 39609329
This particular user, is it a local account or some AD / NIS account?

If local, you can set the password with:
sudo passwd myuser

Open in new window

0
 

Author Comment

by:apunkabollywood
ID: 39609393
Thanks Helge00 - it works - but why its necessary to give password - cant we run a cron job from a password less user?
0
 
LVL 13

Accepted Solution

by:
Daniel Helgenberger earned 500 total points
ID: 39609489
Good question; might be a bug in PAM... anyway; you should not have passwordless users. If you need a job run by a particular user, use roots crontab (either /etc/crontab or a script in /etc/cron.*) with the runuser command:
runuser -u myuser myscript.sh

Open in new window

Note, this is particularly handy with the -m switch; thus preserving root's environment variables.
0
 

Expert Comment

by:shijub
ID: 39622058
you can try disable password ageing for myuser account as below

chage  -m 0 -M -1 -I -1 -E -1 myuser

then do check with

chage -l myuser
0
 
LVL 13

Expert Comment

by:Sandy
ID: 39788148
chage -l user
0
 

Expert Comment

by:shijub
ID: 39790254
user name should be in cron.allow file to enable cron for users.
0
 

Author Closing Comment

by:apunkabollywood
ID: 39814371
Thank you :) its worked
0

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Weird Samba Connectivity Issue... 7 53
linux redhat 7.2 10 90
awk sed 8 68
PHP error function not working on AWS 10 75
Little introduction about CP: CP is a command on linux that use to copy files and folder from one location to another location. Example usage of CP as follow: cp /myfoder /pathto/destination/folder/ cp abc.tar.gz /pathto/destination/folder/ab…
The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question