[redhat-lspp] problem with cron
Raghuveer R
raghuveer at in.ibm.com
Mon Apr 16 06:13:10 UTC 2007
On Thu, 2007-04-12 at 14:17 -0400, Linda Knippers wrote:
> 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.
>
Oh yeah, the test is broken.
> > 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?
>
I did create a file using touch before running the test. Hence i missed
the error. Yes, the tests works fine outside of cron.
Thanks,
Raghuveer
> -- ljk
> >
> > Thanks,
> > Raghuveer
> >
> > --
> > redhat-lspp mailing list
> > redhat-lspp at redhat.com
> > https://www.redhat.com/mailman/listinfo/redhat-lspp
>
> --
> redhat-lspp mailing list
> redhat-lspp at redhat.com
> https://www.redhat.com/mailman/listinfo/redhat-lspp
More information about the redhat-lspp
mailing list