automated terminal push

This commit is contained in:
Your Name
2025-02-13 06:31:06 -05:00
parent 2dbc856a8b
commit 367a5e075b
4 changed files with 3 additions and 6 deletions

49
recycle/cron.bash Executable file
View File

@@ -0,0 +1,49 @@
#!/bin/bash
# Function to create a cron job
create_cron_job() {
user=$1 # Username for the cron job
minute=$2 # Minute of the hour (0-59)
hour=$3 # Hour of the day (0-23)
day_of_month=$4 # Day of the month (1-31)
month=$5 # Month of the year (1-12)
day_of_week=$6 # Day of the week (0-6, Sunday is 0)
command=$7 # Command to execute
# Construct the cron job line
cron_line="${minute} ${hour} ${day_of_month} ${month} ${day_of_week} ${command}"
# Add the cron job for the specified user. Redirects stderr to stdout.
(crontab -u yankee -l 2>/dev/null; echo "$cron_line") | crontab -u yankee -
echo "Cron job added for user $user:"
echo "$cron_line"
}
whoami
# Example usage:
user="yankee"
minute="*" # 4:20 PM
hour="*" # 4 PM in 24-hour format
day_of_month="*" # Every day of the month
month="*" # Every month
day_of_week="*" # Every day of the week
command="cd /yankee-gnome-fire-consumer/; /bin/bash consumer.bash"
create_cron_job "$user" "$minute" "$hour" "$day_of_month" "$month" "$day_of_week" "$command"
# Example with different schedule (e.g., every Monday at 2:00 AM):
# user="yankee"
# minute="0"
# hour="2"
# day_of_month="*"
# month="*"
# day_of_week="1" # Monday (0 is Sunday, 1 is Monday, etc.)
# command="/tmp/another_script.sh"
# create_cron_job "$user" "$minute" "$hour" "$day_of_month" "$month" "$day_of_week" "$command"

44
recycle/schedule.py Normal file
View File

@@ -0,0 +1,44 @@
def write_to_file(filepath, content):
"""Writes content to a file.
Args:
filepath: The path to the file.
content: The string to write to the file.
Returns:
True on success, False on failure. Prints error messages.
"""
try:
with open(filepath, 'w') as f: # 'w' mode overwrites, 'a' appends
f.write(content)
return True
except OSError as e:
print(f"Error writing to file {filepath}: {e}")
return False
# Example usage:
filepath = "/tmp/file.dat" # Or any path you want
content = "yooo"
if write_to_file(filepath, content):
print(f"Successfully wrote '{content}' to {filepath}")
else:
print("File write operation failed.")
# Example of appending:
def append_to_file(filepath, content):
"""Appends content to a file."""
try:
with open(filepath, 'a') as f: # 'a' mode appends
f.write(content)
return True
except OSError as e:
print(f"Error appending to file {filepath}: {e}")
return False
# Example usage of append:
if append_to_file(filepath, "\nand more yooo"): # \n for a new line
print("Successfully appended to the file.")
else:
print("File append operation failed.")

View File

@@ -0,0 +1,33 @@
#!/bin/bash
##
echo "what up????"
set -e
set -x
##
downloadsDir=/home/yankee/Downloads
rm -rf /home/yankee/Downloads
##mkdir $downloadsDir
ln -s /yankee/downloads/ /home/yankee/Downloads
ls -lha $downloadsDir
echo "current dir: "
ls -lha .
##
echo "##"
echo "## launch > yankee gnome > consumer.py?"
echo "##"
python3 consumer.py