i have script being called by my crontab. what the script does is create a mirror of my file server.
I edited the script by adding option to the rsync command by excluding a folder.
I tested the command via the command line with the --exclude option of the rsync on another folder and it work fine, so there’s nothing wrong with my syntax.
But when I checked the cron running the script it still included the files that I indicated in the rsync to exclude.
My question is, if I edited the script being called by the cron, do I need to reload the crontab for the changes in my script to take effect?
Is this a line in /etc/crontab, /etc/cron.d or edited with crontab -e?
If the latter, it should reload after editing. If the former, you have to give it at least a minute to notice the change. This is only for the crontab line. If it calls a script, you would get the latest changes of the script when it is executed.
Remember that a cron job doesn’t get all the settings of a login environment, like $HOME.
> i have script being called by my crontab. what the script does is create
> a mirror of my file server.
>
> I edited the script by adding option to the rsync command by excluding
> a folder.
>
> I tested the command via the command line with the --exclude option of
> the rsync on another folder and it work fine, so there’s nothing wrong
> with my syntax.
>
> But when I checked the cron running the script it still included the
> files that I indicated in the rsync to exclude.
>
> My question is, if I edited the script being called by the cron, do I
> need to reload the crontab for the changes in my script to take effect?
No, your problem must be elsewhere.
Did you test the script, manually?
With the same path before it?
–
Hanlon’s Razor:
Never attribute to malice that which is
adequately explained by stupidity.
neither, it’s a line on a command contained in a script called by the cron
That’s what I have in mind too, since it’s the script that was edited and I didn’t do anything with the crontab, any changes on the script should take effect once the cron starts to run.
Could you please elaborate on this one, I’m quite new to Unix/Linux.
When you login you have an “environment” with a bunch of variables setup
for you like $HOME which points to /home/yourusername for a regular user
or to /root for ‘root’ (defaults). If you are using anything that you
assume is there but it is actually NOT there in your --exclude it may
not work. Basically if your script works cron should work unless you
are using things cron doesn’t provide you which should be fairly easy to
troubleshoot. So with that in mind, run the script as the user cron
uses to run the script and if it works great. If not, that’s weird.
Good luck.
cronk wrote:
> ken_yap;1862231 Wrote:
>> Is this a line in /etc/crontab, /etc/cron.d or edited with crontab -e?
>
> neither, it’s a line on a command contained in a script called by the
> cron
>
> ken_yap;1862231 Wrote:
>> If the latter, it should reload after editing. If the former, you have
>> to give it at least a minute to notice the change. This is only for the
>> crontab line. -If it calls a script, you would get the latest changes
>> of the script when it is executed.-
>
> That’s what I have in mind too, since it’s the script that was edited
> and I didn’t do anything with the crontab, any changes on the script
> should take effect once the cron starts to run.
>
> ken_yap;1862231 Wrote:
>> Remember that a cron job doesn’t get all the settings of a login
>> environment, like $HOME.
>
> Could you please elaborate on this one, I’m quite new to Unix/Linux.
>
> Thank you very much
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
Is anything variable in the real version of your script ?
You might not get the same variable contents in cron as in a regular
console. You might even not have the same name resolution for IP’s.
> this command is contained in a script and the script is being called by
> the cron everyday.
>
> the only thing I added to the original command was the “exclude”
> option. Before I added that, everything was working fine.
Please post the unedited script.
> So I was wondering maybe do I need to reload the crontab after editing
> the script.
No, crontab just starts the script. It doesn’t load into something, that
would need refreshing afterwards.
–
Hanlon’s Razor:
Never attribute to malice that which is
adequately explained by stupidity.