Compare commits

..

2 Commits

Author SHA1 Message Date
Neel Patel
507d2f1a0f Merge 79d446245e into 88e5be6e4b 2025-02-06 17:56:03 +08:00
Nee Patel
79d446245e Adding a cronjob file 2021-07-08 14:15:04 -04:00
3 changed files with 68 additions and 7 deletions

View File

@@ -95,9 +95,3 @@ arr.reduce(callback[, initialValue]) // Apply a function against
arr.reduceRight(callback[, initialValue]) // Apply a function against an accumulator and each value of the array (from right-to-left) as to reduce it to a single value. arr.reduceRight(callback[, initialValue]) // Apply a function against an accumulator and each value of the array (from right-to-left) as to reduce it to a single value.
arr.some(callback[, initialValue]) // Returns true if at least one element in this array satisfies the provided testing function. arr.some(callback[, initialValue]) // Returns true if at least one element in this array satisfies the provided testing function.
arr.values() // Returns a new Array Iterator object that contains the values for each index in the array. arr.values() // Returns a new Array Iterator object that contains the values for each index in the array.
// String methods
String.charAt(index) // Returns the character at the specified index in a string.
String.indexOf(character) // Returns the index of the first occurrence of a specified value in a string.
String.substring(starting_index, ending_index) // Returns a new string that is a subset of the original string.
String.substring(starting_index) // Returns a substring from starting index to last index of string.

68
tools/cronjob.txt Normal file
View File

@@ -0,0 +1,68 @@
CRONTAB, is a time-based job scheduler in Unix like operating systems.
In laymen term, it is used to execute scripts on your machine at a predefined time or interval.
This can be any script, for instance downloading images from a particular website every hour or generating a pdf of your unread emails from the past day and the list goes on
###################################
BASICS
###################################
Each line of a crontab represents a job and it looks as follows:
* * * * * command_name
Each asterisk here has a special meaning :
Asterisk 1 : Represents minutes from 0 to 59
Asterisk 2 : Represents hour of the day from 0 to 23
Asterisk 3: Represents day of the month from 1 to 31
Asterisk 4: Represents a month from 1 to 12
Asterisk 5: Represents the day of the week from 0 to 6 (Sunday to Saturday)
Command : A command that executes a script
Example : 0 10 * * * /bin/bash print_time.sh
You can play with these settings from the following site : https://crontab.guru
The above example will execute the script print_time.sh using the /bin/bash shell, everyday at 10:00 A.M. 
Crontab uses a 24 hour clock
Providing the full path to the script is necessary
Providing a shell name or a specific interpreter is necessary too
We can also use the following strings to define job.
@reboot Run once, at startup.
@yearly Run once a year.
@annually (same as @yearly).
@monthly Run once a month.
@weekly Run once a week.
@daily Run once a day.
@midnight (same as @daily).
@hourly Run once an hour.
@reboot <command-to-execute> # run a job every time the system reboots
###################################
CREATING CRONTAB JOBS
###################################
crontab -e # this opens up the crontab file in your predefined editor
# create a basic cronjob that runs everyday at 10:00 A.M.
0 10 * * * /bin/bash ~/Documents/collect_log.sh
- this cronjob will get executed everyday at 10:00 AM
- note the leading 0 is important
- /bin/bash is the interpreter here, and this is required
- ~/Documents/collect_log.sh is the absolute path to the script to be executed
###################################
VIEW CRONJOBS FOR THE CURRENT USER
###################################
crontab -l
##########################################
REMOVE ALL CRONJOBS FOR THE CURRENT USER
##########################################
crontab -r

View File

@@ -21,7 +21,6 @@ cat /proc/<process_id>/maps # Show the current virtual memory usage of a Linux
ip r # Display ip of the server ip r # Display ip of the server
lsof -i :9000 # List process running on port 9000 lsof -i :9000 # List process running on port 9000
kill -9 $(lsof -t -i:PORT) # Kill the process running on whichever port specified
journalctl -u minio.service -n 100 --no-pager # List last 100 logs for specific service journalctl -u minio.service -n 100 --no-pager # List last 100 logs for specific service