Raghuveer R wrote:
> Hi all,
>
> I am trying to run a cron job on kernel 2.6.18-8.1.1.lspp.73.el5, but it
> is not being executed.
>
> Environment -
> kernel-2.6.18-8.1.1.lspp.73.el5
> crontabs-1.10-8
> vixie-cron-4.1-67.el5
> selinux-policy-mls-2.4.6-55.el5
> selinux-policy-2.4.6-55.el5
> audit-1.3.1-4.el5
>
> I am trying to do the following -
> 1) run_init /etc/init.d/crond restart
> 2) add a cron job as follows
> crontab - << EOF
> `date '+%M' | awk '{ print ($1+2)%60 " * * * * "
> }'` <path to exec>/a.out
> EOF
> where a.out is the following compiled c program -
>
> #include <sys/types.h>
> #include <sys/stat.h>
> #include <fcntl.h>
#include <string.h> will avoid the compiler warning.
>
> main()
> {
> int fd, n;
> char *buf="this is a piece of text\n";
> n = strlen(buf);
> if ( (fd = open("a.txt", O_RDWR, O_CREAT | O_TRUNC)) < 0)
Your test is broken here. I think you want O_RDWR|O_CREAT|O_TRUNC, and a
final argument to define the mode bits. If you run this and the file
doesn't exist your test will fail.
> perror("open");
> else if( write(fd, buf, n) < n )
> perror("write");
> close(fd);
> }
>
> The modification time of a.txt does not change after the cron job is
> supposed to have run.
>
> I do understand that there are better ways of doing this. But the issue
> here is that cron is not running jobs in the above mentioned
> environment.
>
> What could be the problem here?
When I fixed the test program it worked for me. If it doesn't work for
you then I'd start looking for AVCs or some indication of why the program
can't be exec'd or can't open the file. I assume it works for you outside
of cron, right?
-- ljk
>
> Thanks,
> Raghuveer
>
> --
> redhat-lspp mailing list
> [EMAIL PROTECTED]
> https://www.redhat.com/mailman/listinfo/redhat-lspp
--
redhat-lspp mailing list
[EMAIL PROTECTED]
https://www.redhat.com/mailman/listinfo/redhat-lspp