Results 1 to 10 of 10
Hello
I'm using CentOS 6 and I trying my first CRON.
I've this following file /etc/crontab :
Code:
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
# For details see man 4 crontabs
# ...
- 08-27-2011 #1Just Joined!
- Join Date
- Aug 2011
- Location
- FRANCE !
- Posts
- 5
My crontab does not work
Hello

I'm using CentOS 6 and I trying my first CRON.
I've this following file /etc/crontab :
It does not consider my script.sh wich i supposed be executed every hour in the 18th minute... ?Code:SHELL=/bin/bash PATH=/sbin:/bin:/usr/sbin:/usr/bin MAILTO=root HOME=/ # 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,$ # | | | | | # * * * * * command to be executed 37 23 19 8 5 touch cokkkk.txt 18 * * * * /test/script.sh
What is the problem ?
Thank you !
- 08-27-2011 #2
User is missing.
And may I suggest to write systemwide cronjobs in separate files in /etc/cron.d/<TASK>.cron ?You must always face the curtain with a bow.
- 08-27-2011 #3Just Joined!
- Join Date
- Aug 2011
- Location
- FRANCE !
- Posts
- 5
Thanks for your quick reply Irithori !
Please slowly, I try to understand the first function
I've add root, so I've change my line for
and that doesn't change anything !Code:18 * * * * /test/script.sh root
Thank you
- 08-27-2011 #4
The user is before the command
About /etc/cron.d vs /etc/crontab:Code:18 * * * * root /test/script.sh
Crons are easier to manage, if you separate them by task and write files in /etc/cron.d/
Because then you can just delete and add files instead of parsing /etc/crontab to find the right lines.
Also it is easier to define different environments per cronjob.
So in your case:
Create a file /etc/cron.d/my_first_cron.cron
and place your line in there.
On an additional note:
There are tasks and cronjobs, that need to be done as root.
But the goal is to avoid that and use dedicated users for separation and security reasons.You must always face the curtain with a bow.
- 08-27-2011 #5Just Joined!
- Join Date
- Aug 2011
- Location
- FRANCE !
- Posts
- 5
OK that's rulz !
Just one thing, the upload of the script itself dosent' work in CRON MOD.
When I execute the script i'ts ok, script.sh is uploaded. But when the CRON execute the script, it cannot upload the script itself. Do I make myself clear?
Next, I'll try your cron.d.
Thanks
- 08-30-2011 #6Linux Guru
- Join Date
- May 2011
- Posts
- 1,838
What does the cronlog tell you? It is normally found in:
/var/log/cron
You can try redirecting your script output to a log for further trouble-shooting, e.g.:
hthCode:18 * * * * root /test/script.sh > /tmp/cronjob.log 2>&1
- 09-02-2011 #7Just Joined!
- Join Date
- Aug 2011
- Location
- FRANCE !
- Posts
- 5
In cronjob.log, I have :
test.sql and script.sh are in the same directory.Code:Domain=[WIN2003] OS=[Windows Server 2003 R2 3790 Service Pack 2] Server=[Window$ putting file test.sql as \test.sql (174.4 kb/s) (average 174.4 kb/s) script.sh does not exist
Thanks
- 09-02-2011 #8Linux Guru
- Join Date
- May 2011
- Posts
- 1,838
Even though they are in the same directory, the shell running the cronjob probably cannot find them (b/c they are not in its PATH). Try using full path names to any files referenced in your script called by cron.
If you want more help, you can post your cron script, too.
- 09-02-2011 #9Just Joined!
- Join Date
- Aug 2011
- Location
- FRANCE !
- Posts
- 5
The important part of my script.sh is :
THe line of my crontab is :Code:smbclient //192.168.1.xx/onlyuser -A /essais/cred -c "prompt;put test.sql;put script.sh;exit;"
script.sh and test.sql are in the folder :Code:*/1 * * * * root /essais/script.sh >> /logsmb.txt 2>&1
/essais/
When I change "put script.sh" by "put /essais/script.sh" I have this error :
Code:putting file test.sql as \test.sql (111.0 kb/s) (average 111.0 kb/s) NT_STATUS_OBJECT_NAME_INVALID opening remote file \/essais/script.sh
- 09-02-2011 #10Linux Guru
- Join Date
- May 2011
- Posts
- 1,838
Does script.sh already exist on the samba host? Is it open/in use on the samba host? Are the permissions of it such that it cannot be overwritten?
I can emulate your setup on my machine and run it perfectly, as far as I can tell.
Code:Domain=[SAMBA_HOST] OS=[Windows 5.0] Server=[Windows 2000 LAN Manager] putting file test.sql as \test.sql (0.0 kb/s) (average 0.0 kb/s) putting file script.sh as \script.sh (49.3 kb/s) (average 24.7 kb/s)


Reply With Quote