LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Cron not working (https://www.linuxquestions.org/questions/linux-newbie-8/cron-not-working-4175489459/)

seyiisq 12-29-2013 07:35 AM

Cron not working
 
Hello All,
I have been trying to schedule a task using cron only to realise that it is not working.
Code:

$ ps -ef | grep cron
root      2964    1  0 Nov12 ?        00:00:00 crond
root      2178  2964  0 14:20 ?        00:00:00 crond
seyiisq  2228 20774  0 14:20 pts/0    00:00:00 grep cron
$ crontab -l
* * * * * /usr/bin/date >> /xyz/cron_work.log
$

I have checked the file cron_work.log but it was empty.

Please any advise

However, when i queried the log in /var/log i got

Code:

# tail -10 /var/log/cron
Dec 29 14:29:01 computername crond[3215]: (seyiisq) CMD (/usr/bin/date >> /xyz/cron_work.log)
Dec 29 14:30:01 computername crond[3258]: (root) CMD (/usr/lib/sa/sa1 1 1)
Dec 29 14:30:01 computername crond[3260]: (seyiisq) CMD (/usr/bin/date >> /xyz/cron_work.log)
Dec 29 14:31:01 computername crond[3311]: (seyiisq) CMD (/usr/bin/date >> /xyz/cron_work.log)
Dec 29 14:32:01 computername crond[3371]: (seyiisq) CMD (/usr/bin/date >> /xyz/cron_work.log)
Dec 29 14:33:01 computername crond[3431]: (seyiisq) CMD (/usr/bin/date >> /xyz/cron_work.log)
Dec 29 14:34:01 computername crond[3473]: (seyiisq) CMD (/usr/bin/date >> /xyz/cron_work.log)
Dec 29 14:35:01 computername crond[3513]: (seyiisq) CMD (/usr/bin/date >> /xyz/cron_work.log)
Dec 29 14:36:01 computername crond[3570]: (seyiisq) CMD (/usr/bin/date >> /xyz/cron_work.log)
Dec 29 14:37:01 computername crond[3631]: (seyiisq) CMD (/usr/bin/date >> /xyz/cron_work.log)


pingu 12-29-2013 09:33 AM

Check the permissions on directory "/xyz" and on the file /xyz/cron_work.log.

chrism01 12-29-2013 11:41 PM

As per Pingu; generally non-root users cannot write to '/' level dirs.

seyiisq 12-30-2013 01:12 AM

Hi Chrism01,Pingu

The user seyiisq has write to that directory.He even owns the file

seyiisq:computername:/xyz>ls -lrt cron_work.log
-rw-r--r-- 1 seyiisq dba 0 Dec 29 13:10 cron_work.log

Please, can anyone advise

seyiisq 12-30-2013 02:09 AM

I did the cron in seyiisq directory and still had the same result

seyiisq:compoutername:/xyz/seyiisq>crontab -l
* * * * * /usr/bin/date >> /xyz/seyiisq/cron_work.log

seyiisq:computername:/xyz/seyiisq>ls -lrt cron_work.log
-rw-rw-rw- 1 seyiisq dba 0 Dec 29 13:10 cron_work.log

After few minutes of monitoring the file cron_work.log remains empty.

seyiisq 12-30-2013 02:45 AM

Hello All,

This as been resolved.
Thanks to all who responded

pingu 12-30-2013 02:55 AM

Would you mind telling us how, always good to post solutions.
Also please mark thread "solved".

seyiisq 01-01-2014 08:00 PM

I realise that there is no such as /usr/bin/date but /bin/date.

It was a silly mistake on my part

seyiisq 01-02-2014 06:45 AM

Hello All,

I created my own shell script which ran manually but very difficult using cron.
I have been battling with it all day.

*/10 * * * * /full/path/salary.sh

pls can anyone advise


All times are GMT -5. The time now is 07:39 AM.