Question

In: Computer Science

Create a cronjob which does the following tasks 1.) create a file named <yourname>.txt 2.) in...

Create a cronjob which does the following tasks

1.) create a file named <yourname>.txt

2.) in the 35th minute of the hour change the permission to 755

3.) Create a shell script named first.sh in which you print your name and redirect the output by 45th minute of the hour to the text file

Solutions

Expert Solution

We will try to complete the tasks one by one.

1. Create a file named <yourname>.txt. My name is Mohit so I will create mohit.txt. I will create this file in a new task folder in my home directory. You can choose the file location anywhere you want. Command for creating a new file - touch mohit.txt

2. Now we need to change the permission of this file by using corn job. Since permission can be changed by root users, we will edit the /etc/crontab file and add the cronjob there as a root user. We need to change the permission of first.sh so that it becomes executable.

The cron command to run the permission change is-

35 * * * * * root /usr/bin/chmod 755 /home/mohit/task/first.sh

After adding this line to /etc/crontab using - sudo nano /etc/crontab it looks like-

3. Create the shell script in the same task directory by using touch command.touch first.sh

The contents of the script will be-

echo "Mohit"

Either you can redirect the output of this file to text file here or in the cron job. I will do that in the cron job which is a better usage of cron job.

The cron script for this command to be executed at 45th minute will be-

45 * * * * * <username> /home/mohit/task/first.sh -> /home/mohit/task/mohit.txt

Replace <username> with your terminal username. In the screenshots you can see my username is 'mohit'

The updated rontab file will look like-

After this taks has run the contents of file mohit.txt will change and will look lke-

​​​​​​​


Related Solutions

1. create a .txt file and call it fruits.txt, add the following items to the file...
1. create a .txt file and call it fruits.txt, add the following items to the file Apple Banana Peach Strawberry Watermelon Kiwi Grape _______ 2. Write a program that does the following: - Reads the fruit.txt - Converts the contents into all uppercase - Writes the uppercased values into a text file called "UpperFruit.txt" OUTPUT SHOULD BE: APPLE BANANA PEACH STRAWBERRY WATERMELON KIWI GRAPE
Create a file named StudentArrayList.java,within the file create a class named StudentArrayList. This class is meant...
Create a file named StudentArrayList.java,within the file create a class named StudentArrayList. This class is meant to mimic the ArrayList data structure. It will hold an ordered list of items. This list should have a variable size, meaning an arbitrary number of items may be added to the list. Most importantly this class should implement the interface SimpleArrayList provided. Feel free to add as many other functions and methods as needed to your class to accomplish this task. In other...
Exercise 2: You are provided with a text file named covid19-3.txt. It reports a few confirmed...
Exercise 2: You are provided with a text file named covid19-3.txt. It reports a few confirmed cases of covid19. It consists of three columns. The 1st column indicates the names of the provinces, the 2nd column indicates the names of the countries and the 3rd column indicates the numbers of confirmed cases. To do: 1. Define a function that reads, from covid19-3.txt, provinces, countries and confirmed cases in three separate lists. 2. Define a function that iterates through a list...
(Write/read data) Write a Program in BlueJ to create a file name Excersise12_15.txt if it does...
(Write/read data) Write a Program in BlueJ to create a file name Excersise12_15.txt if it does not exist. Write 100 integers created randomly into the file using text I/O. Integers are separated by spaces in the file. Read data back from the file and display the data in increasing order. After writing the file to disk, the input file should be read into an array, sorted using the static Arrays.sort() method from the Java API and then displayed in the...
Create a c++ program with this requirements: Create an input file using notepad ( .txt )...
Create a c++ program with this requirements: Create an input file using notepad ( .txt ) . When testing your program using different input files, you must change the filename inside your program otherwise there will be syntax errors. There are a finite number of lines to be read from the data file. But we can’t assume to know how many before the program executes; so, the standard tactic is to keep reading until you find the “End of File”...
how to create a script file on puTTy script pp1.txt
how to create a script file on puTTy script pp1.txt
Write a python program: There is a file called file 2. File2 is a txt file...
Write a python program: There is a file called file 2. File2 is a txt file and I have written the contents of file 2 below in the exact format it was in notepad. # This comment does not make sense # It is just to make it harder # The job description starts after this comment, notice that it has 4 lines. # This job description has 700150 hay system points\\ the incumbent will administer the spending of kindergarden...
Using node.js, create the following tasks. 1. Set up a server and HTML file server as...
Using node.js, create the following tasks. 1. Set up a server and HTML file server as shown in the videos. Once you have it successfully running, make the following adjustments A. When a 404 error (file not found) occurs, display a funny message about the file missing and/or did you forget how to type? B. If the user enters a request for the home page (index.html) then: Display an index.html page you have created which includes your name, course number,...
Create a c++ program that: Create an input file using notepad ( .txt ). When testing...
Create a c++ program that: Create an input file using notepad ( .txt ). When testing your program using different input files, you must change the filename inside your program otherwise there will be syntax errors. There are a finite number of lines to be read from the data file. But we can’t assume to know how many before the program executes; so, the standard tactic is to keep reading until you find the “End of File” marker. Input date...
II. Big Numbers 1. Implement this program in a file named bigNums.py. 2. Create a numerical...
II. Big Numbers 1. Implement this program in a file named bigNums.py. 2. Create a numerical (integer) list, named numbers. Populate the list with 1,000,000 (one million) integer values with values from 0 to 999,999. Hint: Use the range() function. 3. Print the length of the list to the screen. Ensure you have 1,000,000 items in your list. Hint: Use the len() function. 4. Print the smallest item value in the list to the screen. Hint: use the min() function....
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT