0

If I add up the # in front of some crontab task then it won't work and behave as comment ? right ? I want to disable some task for sometime until I like to enable.

# * * * * /home/user/xx

Thanks

2 Answers 2

1

Yes, # in front of a line in cron comments it out.

It will also comment out anything following it if it's part way through a line.

You do NOT need to restart cron to make changed crontabs take effect, otherwise any user that changed their own crontab would need root access to restart cron to make their own crontab take effect.

What you DO need is for cron to re-read your crontab, which you can do in various ways. The safe way to edit your crontab is to do list it into a file with:

crontab -l > my.crontab

Then edit the file (in this case: my.crontab) and then load the file back into cron:

crontab ./my.crontab

If it's only a small edit that you're making, you can do it inline with:

crontab -e

which will open your crontab in the editor you have set in your $EDITOR environment variable.

Both of these methods will check the syntax of your crontab, load it, and get cron to re-read it. Where you get into trouble is when you try editing the crontab file directly on disk and then don't do anything to tell cron to re-read it.

0

The #-Sign is for commenting text in crontabs.

But, after editing the crontab you have to restart cron to make changed take effect. Use this command:

user@host:~# sudo service cron restart

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .