Posts

Hamidreza Talebi, linux

You can set schedule in linux with this command:

$ crontab -e

for example:

We want our job to run at 5 A.M., which would be minute 0, hour 5, every day of the month, every month, every day of the week. We need to add a line to the bottom of the file which looks like this:

0 5 * * * /home/myname/scripts/do-every-day.sh

for backup everyday at 12:02 AM

2 0 * * * tar -zcf  /home/hrt/Desktop/backup/$(date +\%H-\%M-\%S-\%d-\%m-\%Y).tar.gz  /usr/local/bro/logs>/dev/null 2>&1

for fixing bug in ubuntu you have to add >/dev/null 2>&1 to every crontab you define.

For checking your crontab, use this command:

$crontab -l

For removing crontab just add this one:

$crontab -r

For viewing logs run  this command:

sudo grep -i cron /var/log/syslog