How to Set a Daily Reminder Notification Using Termux:API
How to Set a Daily Reminder Notification Using Termux:API
If you have ever wanted to turn your Android phone into a personal productivity powerhouse without installing bloated third-party apps, you are in the right place. Today, we are looking at how to set a daily reminder notification using Termux:API. By combining the power of the Linux command line with your phone's native notification system, you can build a lightweight, custom alert system that runs entirely on your device.
Welcome to termuxgenius.com. Whether you are trying to remember to drink water, stretch, or execute a routine backup, automating your alerts gives you absolute control over your digital life. Let us dive right into building your very own termux daily reminder script from scratch.
Quick Summary: What You Need to Know
Setting up programmatic alerts on Android via the command line requires a few specific components working together. Here is a quick breakdown:
- Termux: The core terminal emulator app that acts as your Linux environment.
- Termux:API: An add-on app and package that bridges Termux with your Android operating system hardware and software features.
- Termux-Notification: The specific command used to push custom titles, messages, and IDs to your notification shade.
- Automation: A method to trigger the script at the exact same time every single day.
Featured Snippet Answer: How to Trigger a Termux Notification
To send a notification from Termux, you must install the Termux:API package and run the termux-notification command. The basic syntax looks like this:
termux-notification --title "Daily Reminder" --content "Time to stretch!"
This command instantly pushes an alert to your Android notification bar using native system channels.
Prerequisites: Getting Your Environment Ready
Before we write any code, we need to make sure your phone has the right tools installed. Since we are dealing with system-level integrations, standard Termux alone won't be enough. You need the helper bridge.
- Download and install Termux. (Note: Avoid the outdated Google Play Store version; get it from F-Droid or GitHub for proper package maintenance).
- Download and install the Termux:API app from the same source (F-Droid). This app acts as the permission gateway between the terminal and Android.
- Open your terminal app and update your package lists by running:
pkg update && pkg upgrade -y - Install the API package inside Termux:
pkg install termux-api -y
Once those steps are complete, your phone is ready to receive commands from the command line.
The Core Script: Your Copy-Paste Ready Solution
Let us get straight to what you came for. Below is a clean, fully functional Bash script designed to handle your daily prompts. It meets our primary search intent for a termux daily reminder script.
Create a new file named daily_reminder.sh using your favorite text editor (like nano) or by running the following command:
cat << 'EOF' > daily_reminder.sh
#!/bin/bash
# ==========================================
# Script Name: Daily Reminder Notification
# Description: Sends a customized daily alert
# ==========================================
# Configuration Variables
TITLE="Termux Genius Reminder"
MESSAGE="Stay focused! Check your daily goals and keep moving forward."
NOTIFICATION_ID=1001
# Execute the notification command
termux-notification \
--id "$NOTIFICATION_ID" \
--title "$TITLE" \
--content "$MESSAGE" \
--priority high \
--sound
echo "Notification sent successfully at $(date)"
EOF
Make the script executable by running this permission command in your terminal:
chmod +x daily_reminder.sh
Line-by-Line Explanation of the Script
Understanding what your code does is vital for security and customization. Let us break down every single line of our automation script:
#!/bin/bash: This is the shebang line. It tells the operating system which interpreter to use for executing the script—in this case, the standard Bash shell.TITLE="..."andMESSAGE="...": These variables store the text that will appear on your screen. You can change these strings to whatever reminder text you prefer.NOTIFICATION_ID=1001: Assigning a specific ID ensures that if you trigger multiple alerts, new notifications can either update the existing one or stack cleanly depending on your configuration.termux-notification \: This is the core binary command provided by the Termux:API package. The backslash allows us to split a long command across multiple lines for readability.--id "$NOTIFICATION_ID": Passes our defined number to the API.--title "$TITLE": Sets the bold header text of the popup alert.--content "$MESSAGE": Sets the body text describing the reminder.--priority high: Tells Android to treat this alert with urgency, which helps bypass quiet rules or sleepy UI states on certain manufacturer builds.--sound: Forces the device to play your default notification sound when the alert drops.echo "...": Prints a timestamped confirmation message to your terminal log so you know the script executed.
How to Auto-Run It: Scheduling Your termux-notification schedule daily Routine
A reminder script is useless if you have to run it manually every day. To truly automate this, we need a scheduling mechanism. While traditional Linux uses Cron, Android's aggressive battery management often kills background daemon processes. Therefore, we have two primary paths to explore.
Method 1: Using Termux:Boot (Recommended for Reliability)
If you want a script to manage background routines or run at specific intervals upon device startup, the Termux:Boot add-on is fantastic. However, for precise time-of-day scheduling without root access, combining a background loop or using a dedicated tasker app works best.
Let us look at a lightweight infinite loop method that runs directly inside a background terminal session using nohup and sleep:
nohup bash -c '
while true; do
# Calculate seconds until the next desired run, or run daily check
./daily_reminder.sh
sleep 86400
done
' > /dev/null 2×1 &
Note: 86400 seconds equals exactly 24 hours. While simple, if you restart your phone, this background job will clear unless added to your ~/.bashrc or a Termux:Boot script.
Method 2: Integration with Tasker or MacroDroid
Many advanced users prefer using automation apps like Tasker or MacroDroid alongside Termux. You can create a time-based profile in Tasker (e.g., trigger every day at 9:00 AM) and execute a single task that calls your Termux script via a plugin or intent. This method avoids Android battery optimization traps entirely.
Comparison of Automation Methods
| Method | Pros | Cons |
|---|---|---|
| Termux Loop (Sleep) | Pure command line, no extra apps needed. | Stops if the phone force-closes background wakelocks. |
| Tasker + Termux | Rock-solid reliability, handles battery saver modes well. | Requires external paid apps and plugins. |
| Termux:Boot | Starts tasks automatically when your phone boots up. | Requires the Termux:Boot extension app. |
Safety, Legal, and Battery Notes
When running background scripts on mobile operating systems, you must keep resource consumption in mind. Here are a few important guidelines to keep your device healthy:
- Battery Optimization: Modern versions of Android (Android 11, 12, 13, and 14) aggressively kill background processes to save power. You must go into your system settings, locate the Termux app, and set battery usage to "Unrestricted" if you expect scheduled scripts to fire reliably.
- Permissions: Never grant broad storage permissions unless your script actually needs to read or write files. For simple notifications, the API bridge is all you need.
- Privacy: Everything executed here stays 100% local on your hardware. No cloud servers are pinged to deliver your daily reminder.
Common Mistakes to Avoid
Even experienced Linux users sometimes run into roadblocks when moving scripts to Android. Watch out for these common pitfalls:
- Forgetting the API App: Installing the
termux-apipackage via apt is only half the battle. If you do not have the Termux:API companion app installed from F-Droid, your commands will hang or throw connection errors. - Incorrect Pathing: When setting up automation loops, always use absolute paths (e.g.,
/data/data/com.termux/files/home/daily_reminder.sh) instead of relative paths, or your scheduler won't find the file. - Ignoring Execution Permissions: If your script outputs a "Permission Denied" error, you forgot to run
chmod +x filename.sh.
Expert Tips for Advanced Customization
Want to take your reminder system to the next level? Try these modifications:
- Dynamic Content: Modify your script to pull a random quote from a text file every morning using the
shufcommand. - Action Buttons: The
termux-notificationutility supports action buttons. You can add interactive buttons that let you snooze the reminder or mark a task complete right from the notification shade. - Network Checks: Add an
pingorcurlcheck inside your script so it only alerts you when you are connected to your home Wi-Fi network.
Frequently Asked Questions (FAQ)
1. Why is my Termux notification not showing up?
Make sure you have installed both the termux-api deb package and the Termux:API Android application. Also, check your phone's notification settings to ensure Termux is allowed to push alerts.
2. Can I schedule scripts without keeping my phone awake?
Yes, Android handles scheduled alarms using Doze mode. However, if your background loops rely purely on a sleep command, Android may suspend the CPU. Using Tasker or Alarm-based triggers provides better deep-sleep compatibility.
3. How do I stop a running background reminder loop?
If you started a background loop using nohup, find its process ID by running ps aux | grep bash and terminate it using kill [PID].
Conclusion
You have successfully built, configured, and learned how to maintain a termux daily reminder script using native tools. By taking control of your device's notification system through the command line, you open the door to endless mobile automation possibilities without sacrificing your privacy.
Ready to automate more of your workflow? Check out our other guides at termuxgenius.com to discover advanced backup routines, file management tricks, and terminal workflows designed for Android power users.
Join the conversation