Hi @Nehra sir, I have a question - If anacron executes the commands whenever the system is turned On, how will the source machine will get to know that the target machine is turned On. Will the source machine be running some background checks or pings. Pls explain.
Anacron is a job scheduler used on Unix-like operating systems to execute commands periodically with a frequency specified in days. Unlike cron, which assumes that the system is always running, Anacron is designed for systems that are not always powered on. Anacron does not natively provide a way for one machine (the source machine) to know when another machine (the target machine) is turned on.
Scheduling cron jobs for a user other than root and setting up email notifications involves a few steps. Here’s a detailed guide: ### **1. Scheduling a Cron Job for a Specific User** To schedule a cron job for a user other than root, you need to edit that user’s crontab file. Here’s how to do it: 1. **Switch to the User (if you are root or using `sudo`):** ```bash sudo su - username ``` Replace `username` with the target user’s name. 2. **Edit the User’s Crontab:** ```bash crontab -e ``` This opens the crontab file for the user in the default text editor. 3. **Add a Cron Job:** Add the cron job in the following format: ```bash * * * * * /path/to/script.sh ``` Replace `* * * * *` with the desired schedule and `/path/to/script.sh` with the path to your script. Example to run a script every day at 3 AM: ```bash 0 3 * * * /home/username/scripts/myscript.sh ``` 4. **Save and Exit:** Save the file and exit the editor. The cron job is now scheduled. ### **2. Scheduling a Cron Job as Root for Another User** If you need to schedule a cron job for another user from the root account, use the following steps: 1. **Edit the System-Wide Crontab:** You can edit the system-wide crontab file to schedule jobs for other users: ```bash sudo nano /etc/crontab ``` Add a line specifying the user, schedule, and command: ```bash * * * * * username /path/to/script.sh ``` Replace `username` with the target user’s name and adjust the schedule and script path as needed. 2. **Save and Exit:** Save the changes and exit the editor. ### **3. Setting Up Email Notifications for Cron Jobs** To receive email notifications for cron jobs, ensure the following: 1. **Mail Transfer Agent (MTA) Configuration:** - Make sure an MTA like `sendmail`, `postfix`, or `exim` is installed and configured on your system. This allows cron to send emails. 2. **Set `MAILTO` in Crontab:** Add the `MAILTO` environment variable to the user’s crontab file or the system-wide crontab file to specify the recipient email address: ```bash MAILTO="your-email@example.com" ``` Example crontab entry: ```bash MAILTO="your-email@example.com" 0 3 * * * /home/username/scripts/myscript.sh ``` If `MAILTO` is not set, cron will send the email to the user account running the cron job by default. ### **4. Verify Cron Job Execution** 1. **Check Logs:** - Verify if the cron job executed and if emails were sent: ```bash sudo grep CRON /var/log/syslog ``` - On some systems, cron logs are stored in `/var/log/cron` or `/var/log/cron.log`. 2. **Test the Script:** - Run the script manually to ensure it works correctly and check for any issues. By following these steps, you can schedule cron jobs for users other than root and ensure you receive email notifications for the execution of these jobs.
at now +2min -m and at now +2min -M can you please explain this command again? you have mention we can get email by using m option, where can we see mail
Dheere dheere se nahi, properly announce karke hi lagayi hai. Aur next month se poora course standard nahi balki advanced level par access hoga. Jab na koi share kar rha hai a likes target complete kar rha hai, ulta log videos download karke rakh lete hain to hame bhi membership lagani hi padi.
nice session
excellence on excellent level sir.
Thanks 🙏
thank you so much
Great Session .
Crontab 28:35
please dont stop your hard work. you are great
Thanks
Class starts 3:57
Hi @Nehra sir,
I have a question - If anacron executes the commands whenever the system is turned On, how will the source machine will get to know that the target machine is turned On.
Will the source machine be running some background checks or pings.
Pls explain.
Anacron is a job scheduler used on Unix-like operating systems to execute commands periodically with a frequency specified in days. Unlike cron, which assumes that the system is always running, Anacron is designed for systems that are not always powered on.
Anacron does not natively provide a way for one machine (the source machine) to know when another machine (the target machine) is turned on.
Hi Sir ,
how to schedule cron for other user apart from root and schedule jobs and i need to get a mail for the script in cron.
Scheduling cron jobs for a user other than root and setting up email notifications involves a few steps. Here’s a detailed guide:
### **1. Scheduling a Cron Job for a Specific User**
To schedule a cron job for a user other than root, you need to edit that user’s crontab file. Here’s how to do it:
1. **Switch to the User (if you are root or using `sudo`):**
```bash
sudo su - username
```
Replace `username` with the target user’s name.
2. **Edit the User’s Crontab:**
```bash
crontab -e
```
This opens the crontab file for the user in the default text editor.
3. **Add a Cron Job:**
Add the cron job in the following format:
```bash
* * * * * /path/to/script.sh
```
Replace `* * * * *` with the desired schedule and `/path/to/script.sh` with the path to your script.
Example to run a script every day at 3 AM:
```bash
0 3 * * * /home/username/scripts/myscript.sh
```
4. **Save and Exit:**
Save the file and exit the editor. The cron job is now scheduled.
### **2. Scheduling a Cron Job as Root for Another User**
If you need to schedule a cron job for another user from the root account, use the following steps:
1. **Edit the System-Wide Crontab:**
You can edit the system-wide crontab file to schedule jobs for other users:
```bash
sudo nano /etc/crontab
```
Add a line specifying the user, schedule, and command:
```bash
* * * * * username /path/to/script.sh
```
Replace `username` with the target user’s name and adjust the schedule and script path as needed.
2. **Save and Exit:**
Save the changes and exit the editor.
### **3. Setting Up Email Notifications for Cron Jobs**
To receive email notifications for cron jobs, ensure the following:
1. **Mail Transfer Agent (MTA) Configuration:**
- Make sure an MTA like `sendmail`, `postfix`, or `exim` is installed and configured on your system. This allows cron to send emails.
2. **Set `MAILTO` in Crontab:**
Add the `MAILTO` environment variable to the user’s crontab file or the system-wide crontab file to specify the recipient email address:
```bash
MAILTO="your-email@example.com"
```
Example crontab entry:
```bash
MAILTO="your-email@example.com"
0 3 * * * /home/username/scripts/myscript.sh
```
If `MAILTO` is not set, cron will send the email to the user account running the cron job by default.
### **4. Verify Cron Job Execution**
1. **Check Logs:**
- Verify if the cron job executed and if emails were sent:
```bash
sudo grep CRON /var/log/syslog
```
- On some systems, cron logs are stored in `/var/log/cron` or `/var/log/cron.log`.
2. **Test the Script:**
- Run the script manually to ensure it works correctly and check for any issues.
By following these steps, you can schedule cron jobs for users other than root and ensure you receive email notifications for the execution of these jobs.
Love you sir
at now +2min -m and at now +2min -M
can you please explain this command again? you have mention we can get email by using m option, where can we see mail
What is different between jobs should and Crontab
Sir whtat is the command for the show output in the terminal
already explained
Best'
best
Sir If I execute any job in every 90 min through crontab how can I do that?
30 1 * * * type your schedule job
You have to set two jobs for this task
Where is session 64?
Available in the playlist for the members
Sir app ne dhere dhere sab video membersship k liye kar d. 😢😢😢
Dheere dheere se nahi, properly announce karke hi lagayi hai. Aur next month se poora course standard nahi balki advanced level par access hoga.
Jab na koi share kar rha hai a likes target complete kar rha hai, ulta log videos download karke rakh lete hain to hame bhi membership lagani hi padi.
please make videos in english
already uploaded
Hindi sub translation very disturbing
you have the option to turn it off or auto transcribe to your language.